Reputation: 3751
How can I update the remote branches list in Git?
I have pushed a branch to Git on the server. On the second local copy of the repository, I want to get that branch and do:
show branch -r
But I don't have the new branch in this list.
How can I update Git's remote branch list?
Upvotes: 27
Views: 34851
Reputation: 335
Execute the command:
git fetch --all
So the local repository will download all the new branches/tags that is in the server.
If you want to remove from the local the ones that have been removed from the remote server, try this:
git fetch --all --prune
As seen in the git doc about the fetch command.
Upvotes: 12
Reputation: 4250
You can use the following commands to update the list of local branches from remote:
git fetch --prune
git pull --prune
Also you can set to update the local list of remote git branches automatically every time you run git pull
or git fetch
using below command.
git config remote.origin.prune true
Upvotes: 26
Reputation: 4626
In the second local repository:
git fetch # Retrieves updates from remote repo
git branch -a # View all local and remote branches
Upvotes: 13