I cloned a Git repository, which contains about five branches. However, when I do git branch
I only see one of them:
$ git branch
* master
Track all branches that exist in the remote repo.
Manually do it:
You would replace
with a branch that is displayed from the output of git branch -r
.
git branch -r
git branch --track
Do it with a bash script
for i in $(git branch -r | grep -vE "HEAD|master"); do git branch --track ${i#*/} $i; done
This fetches updates on branches from the remote repo which you are tracking in your local repo. This does not alter your local branches. Your local git repo is now aware of things that have happened on the remote repo branches. An example would be that a new commit has been pushed to the remote master, doing a fetch will now alert you that your local master is behind by 1 commit.
git fetch --all
Does a fetch followed by a merge for all branches from the remote to the local branch. An example would be that a new commit has been pushed to the remote master, doing a pull will update your local repo about the changes in the remote branch and then it will merge those changes into your local branch. This can create quite a mess due to merge conflicts.
git pull --all