How to view your branches from the command line – 120

Now that you’ve seen how to do fetches, merges, and pulls from a remote tracking branch within Visual Studio, let’s rinse and repeat from the command line. Personally, it’s been easier to first grasp these concepts using Visual Studio, then rinse and repeat at the command line level.

I have to know the truth behind what the UI is doing šŸ™‚

If you want to view the full list of remotes, similar to the full list shown in Team Explorer – Branches

list of branches in Team Explorer

From the command line, you can do

$ git branch -a

You’ll see the same list (well almost the same list. I’m not sure yet what the remotes/origin/HEAD is doing yet… stay tuned unless someone wants to beat me to the answer in the comments!)

Note how the local branch `for-review` is listed first (which kinda gets blended in color-wise with the command), then master, then the remote tracking branches.

git branch -a from command line

Something that has confused me for a long time until I wrote yesterday’s post was whether “remotes/origin/why-not” was the same as “origin/why-not” or even the made-up “remotes/why-not” (which I don’t think a branch is ever referred to as such). Now that I can visualize what both the command line and Visual Studio are doing, it’s easier to get my head wrapped around these remote tracking branches.

Leave a comment