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?
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.
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 .
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!
new BranchConfig(repo.getConfig(), repo.getBranch()).getTrackingBranch()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With