Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (29.3k points)
edited by

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?

1 Answer

0 votes
by (50.2k points)


“[<branchname>]@{push}, e.g. [email protected]{push}, @{push}

The suffix @{push} reports the branch "where we would push to" if git push were run while branchname was checked out (or the current HEAD if no branch name is specified). Since our push destination is in a remote repository, of course, we report the local tracking branch that corresponds to that branch (i.e., something in refs/remotes/).”

From the above documentation clearly mentions that you can find the upstream of the branch using:

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



git rev-parse --abbrev-ref [email protected]{upstream}

Browse Categories