Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » checkout with setUpstreamMode doesn't update config
checkout with setUpstreamMode doesn't update config [message #898742] Fri, 27 July 2012 12:19 Go to next message
ZFabrik Missing name is currently offline ZFabrik Missing nameFriend
Messages: 3
Registered: April 2011
Junior Member
Hi all,

I must say that I'm not a Git expert and so I'm not a jgit expert as well Wink
So maybe the problem is in my approach and not in jgit Wink

I'm using org.eclipse.jgit-2.0.0.201206130900-r.jar.

There's a remote repository with two branches 'master' and 'v2.0', v2.0 is the active one.

Now I want to clone this repository and checkout master as remote tracking branch:

Git repo = Git.cloneRepository().
  setURI(remoteUrl).
  setCloneAllBranches(true).
  setNoCheckout(false).
  setDirectory(repoDir).
  call();

repo.branchCreate().
  setUpstreamMode(SetupUpstreamMode.TRACK).
  setName(branch).
  call();


Now when I want to update my local repo via
new Git(repo).pull().call();
jgit throws an "no values for key branch.master.merge" found in configuration" exception.

This is because there is no section inside the config:

[branch "master"]
remote = origin
merge = refs/heads/master

However when using the c-git, this section is created automatically:
$ git clone <remote-repo>
$ cd <repo>
$ git checkout -t origin/master
$ cat .git/config
...
[branch "v2.0"]
	remote = origin
	merge = refs/heads/v2.0
[branch "master"]
	remote = origin
	merge = refs/heads/master


What am I doing wrong?


Thanks in advance and best regards
Udo

Re: checkout with setUpstreamMode doesn't update config [message #898811 is a reply to message #898742] Fri, 27 July 2012 17:52 Go to previous message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
ZFabrik Mising name skrev 2012-07-27 14.19:> Hi all,
> I must say that I'm not a Git expert and so I'm not a jgit expert as
> well ;)
> So maybe the problem is in my approach and not in jgit ;)
>
> I'm using org.eclipse.jgit-2.0.0.201206130900-r.jar.
>
> There's a remote repository with two branches 'master' and 'v2.0', v2.0
> is the active one.
>
> Now I want to clone this repository and checkout master as remote
> tracking branch:
>
>
> Git repo = Git.cloneRepository().
> setURI(remoteUrl).
> setCloneAllBranches(true).
> setNoCheckout(false).
> setDirectory(repoDir).
> call();
>
> repo.branchCreate().
> setUpstreamMode(SetupUpstreamMode.TRACK).
> setName(branch).
> call();

You must call setStartPoint so JGit knows what branch to track, just
as you did with C Git.

-- robin
Previous Topic:Push to upstream - confusing dialogue
Next Topic:Add Existing Local Repository programmatically
Goto Forum:
  


Current Time: Thu Apr 25 14:37:39 GMT 2024

Powered by FUDForum. Page generated in 0.03098 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top