P.Brian.Mackey P.Brian.Mackey - 5 months ago 23
Git Question

Why does git branch not list a newly created branch?

A peer created a new branch. I ran

git pull
to get the latest updates on the remote repo. Then I ran
git branch
and I did not see his new branch. So I tried
git checkout newBranch
and it worked. Now when I run
git branch
it displays

Why did
git branch
only update after I ran
instead of after


Because as far as I understand it git branch only lists your local branches. Your repository still has the remote branch there, hence why you can checkout the branch. And once you checkout that branch you've create your local version of said branch.

Hence why git branch now shows the branch after you checked it out.

git branch -a - Lists all branches, both local and remote-tracking branches
git branch or git branch --list - Lists all existing local branches
git branch -r - Lists remote-tracking branches