0 votes
1 view
in Devops and Agile by (29k 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 (49.5k points)

Reference: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt-emltbranchnamegtupstreamemegemmasterupstreamememuem 

“[<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}

refs/remotes/origin/master

Example: 

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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...