Back
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?
Reference: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt-emltbranchnamegtupstreamemegemmasterupstreamememuem
“[<branchname>]@{push}, e.g. master@{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/).”
“[<branchname>]@{push}, e.g. master@{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
git rev-parse --symbolic-full-name @{upstream}
refs/remotes/origin/master
Example:
git rev-parse --abbrev-ref master@{upstream}
31k questions
32.8k answers
501 comments
693 users