final Git repoAgit = Git.cloneRepository()
.setURI(repoAgitUrl)
.setDirectory(new File(repoApath))
.setBranchesToClone(Arrays.asList("refs/heads/develop"))
.setBranch("refs/heads/develop")
.setTransportConfigCallback(TRANSPORT_CONFIG_CALLBACK)
.call();
final Git repoBgit = Git.cloneRepository()
.setURI(repoBgitUrl)
.setDirectory(new File(repoBpath))
.setBranchesToClone(Arrays.asList("refs/heads/develop"))
.setBranch("refs/heads/develop")
.setTransportConfigCallback(TRANSPORT_CONFIG_CALLBACK)
.call();
How do I merge repoA into repoB, where repoA is supposed to be ahead of repoB, and repoB is a forked version of repoA?
First, in
repoB, create a remote that referencesrepoA.Then fetch from this remote so that there are two local branches:
refs/heads/developandrefs/remotes/repoa/develop.If not yet done, checkout the target branch
refs/heads/developin repoB.Call the
MergeCommandto merge the remote tracking branch into HEAD.For example: