JGit FetchCommand

风流意气都作罢 提交于 2019-12-06 04:26:22
Vince

I think you missed something. in Git/jGit, a local copy is determined by a path (like in a file system), and a remote, which is a distant repo.

In your case, you want that your desktop cloned repo has a link to your jGitClone/jGit repo. So first, if the cloning is already done, then the desktop repo knows about its remote repo. So in your code, you just need to tell where your desktop repo is:

Builder builder = new FileRepositoryBuilder()
Git repo = builder.setGitDir(new File("C:\Users\user\Desktop\jGitClone.git"))
  .readEnvironment()
  .build()

The code might not be directly working (I didn't test it, the doubts I have are on the path to give, and the objects to use: Builder, Git), but it's based on this answer that I think will help you: JGit and finding the Head

By the way, your question is not that clear : did you already clone everything or is it what you want to do? in your code you mention a repository : did you obtain it using code similar to what I suggested? The names you chose are not very clear either : calling a repo jGit, unless it contains jGit source code, sounds a bit clumsy. Plus, give names to your different repos (A,B,C) to have a clearer understanding.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!