今天,我簽署了github上,並使用這裏描述的技術轉換現有的文件系統到一個混帳回購協議:使用JGit提交併推送到GitHub - 裸回購?
最重要的(我覺得)它涉及這一行:
git --bare init
然後我跟着github.com的其他設置教程(這是其中的一部分),並完成了。現有的文件系統在Dropbox中,所以我在其他兩臺使用文件系統的機器(現在是git repo)上執行相同的設置。
今晚我試着讓JGit添加一個文件,提交併推送它。這是代碼的要點,直到它突破點:
FileRepositoryBuilder builder = new FileRepositoryBuilder();
Repository repository = builder.setGitDir(new File("path/to/my/repo"))
.readEnvironment() // scan environment GIT_* variables
.findGitDir() // scan up the file system tree
.build();
Git git = new Git(repository);
AddCommand add = git.add();
try{
add.addFilepattern("PlayState.as").call();`
這基本上是逐字從JGit教程,順便說一句。在這一點最後報價行拋出異常,並指出:
org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index
at org.eclipse.jgit.lib.Repository.getIndexFile(Repository.java:838)
at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:886)
at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:136)
at flipa.FLIPAGame.writeToFlixel(FLIPAGame.java:77)
at flipa.FLIPAGame.main(FLIPAGame.java:58)
現在,我不是說聲稱,因爲說實話我不是版本控制的最好的朋友,這是不合理的。我得到一個光禿禿的回購是一個只有混帳和沒有其他文件,但在我看來,現在它有文件。我已經手動添加,提交併使用終端上的git推送到github。所以我不能立即明白爲什麼它甚至不會承認回購。
任何接受者?
編輯 - 爲了澄清,如果有人可以提出另一種解決方案,殺死這個回購沒有什麼大不了的。我想要一個git repo來使用我的Dropbox中的文件系統,並且能夠通過Java提交給github。
是的,它與Dropbox的開始,現在想實際的版本控制,而不是備份,並試圖將兩者攪和的症狀。爲了可怕的結果。 感謝您編寫清晰易讀的回覆,我今天在研究Git時遇到了麻煩。我會睡在這裏,並在早上發作。我會讓你知道它是怎麼回事! – mtrc