Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine Tracking Branch in JGit

Tags:

jgit

I would like to determine the remote tracking branch of HEAD using JGit.

In straight git, I can do:

git rev-parse --abbrev-ref --symbolic-full-name @{upstream}

How can I do this in JGit?

like image 469
Christian Goetze Avatar asked Mar 14 '15 00:03

Christian Goetze


People also ask

How do you check which branch my branch is tracking?

There is a command that gives you about all tracking branches. And to know about the pull and push configuration per branch you can use the command git remote show origin. and you can use -sb option for seeing the upstream. Hope this information will help you to find which branch is tracking.

What is tracking branch in git GUI?

Tracking branches are local branches that have a direct relationship to a remote branch. If you're on a tracking branch and type git pull , Git automatically knows which server to fetch from and which branch to merge in. Now, your local branch sf will automatically pull from origin/serverfix .

How do I change the tracking on my remote branch?

You need to unset the current remote tracking branch first: git branch --unset-upstream - then it works as given in this answer (or with the next git push -u / --set-upstream ). Thanks!


1 Answers

new BranchConfig(repo.getConfig(), repo.getBranch()).getTrackingBranch()
like image 192
Christian Goetze Avatar answered Sep 16 '22 15:09

Christian Goetze