Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I see which Git branches are tracking which remote / upstream branch?

Tags:

git

I know I can do git branch --all, and that shows me both local and remote branches, but it's not that useful in showing me the relationships between them.

How do I list branches in a way that shows which local branch is tracking which remote?

like image 954
joachim Avatar asked Feb 09 '11 21:02

joachim


People also ask

How can I tell which remote branch I am 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.

Does git branch show remote branches?

To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands. If you approve the changes a remote branch contains, you can merge it into a local branch with a normal git merge .


1 Answers

Very much a porcelain command, not good if you want this for scripting:

git branch -vv   # doubly verbose! 

Note that with git 1.8.3, that upstream branch is displayed in blue (see "What is this branch tracking (if anything) in git?")


If you want clean output, see arcresu's answer - it uses a porcelain command that I don't believe existed at the time I originally wrote this answer, so it's a bit more concise and works with branches configured for rebase, not just merge.

like image 139
Cascabel Avatar answered Sep 16 '22 12:09

Cascabel