A peer created a new branch.
I ran
git pull
git branch - I did not see his new branch.
So then I...
git checkout newBranch
git branch - Now I see his new branch
Why did git branch only update after I ran checkout instead of after pull?
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 If you want to see all branches on the remote repo you can use
git branch -a I normally use this with grep to find the branch I want.
git branch -a |grep <what I want> If you just create a branch with the same name as your peer's branch it won't work you have to base it off of the remote branch
Your peer has to push to the central repo with something like
git push --set-upstream origin <branch name> To base your branch off of the remote branch you can use
git checkout -b <branch_name> origin/<branch name> git checkout newBranch. I checked git log and I see his changes.git branch lists local branches. It is available but it is still a remote branch if you haven't created a local branch to track it. By doing git checkout newBranch I think git assumed you wanted to track the equivalent branch on the remote repo and hence you created your local branch and now git branch lists it.git branch shows local branches
to list remote branches :
git branch -a to get all the remote branches :
git fetch then you can
git checkout newBranch git pull and that is similar to running git fetch. Since the branch is now a local branch why does it not show when I run git branch?git checkout origin/newBranch but this would still leave him in a detached head state.In your case git checkout doesn't really check out the remote branch newName, instead it creates a shiny new local branch newName which is set up to track the remote branch.
Thus by checking out "newBranch" you also created an equally named local branch "newBranch" which is then naturally shown by git branch