I m trying to update the local list of my branches. I can see only 3 while remote are 11. I tried this solution with prune command and despite my config file was updated when I press git branch -a I get the same result as before (the remote branches with red letters and in first place 'remotes/origin/HEAD->origin/master'.
2 Answers
If you don't see the branches after the command you entered, it probably means they don't exist locally. Your computer now knows they exist, but hasn't physically and locally created them yet. Switch to one of the remote branches that are "missing":
git checkout branch_name
... and git should create the branch locally.
Also, remember that git remote update
fetches from ALL REMOTES, while what you probably want to do (what is probably sufficient enough) is git fetch origin
which fetches only from one remote called origin. It probably doesn't change much in your case, but please make sure you understand the difference.
Further clarification in response to comment
git fetch
downloads objects and refs from a remote repository - ONE repository only. So git fetch origin
will download all that stuff from the repository called origin.
If you you use git remote update
, it will download objects and refs from ALL repositories (in case you more the just origin configured - you probably don't). It is essentially the same as you would execute git fetch --all
.
To summarize, you usually want to use git fetch origin
- this will update your local state with regards to what exists remotely. Updating doesn't mean it will physically create the branches for you. It's just information that they exist and may be checked out. It is git checkout branch_name
which then creates a selected branch physically on your local computer.

- 1,560
- 6
- 19
- 23
-
Thank you very much for your help. I understood git remote update, but I m afraid I dont understand exactly what happens when I fetch from origin.. – Dimitrios Markopoulos Sep 10 '17 at 11:45
-
You're welcome. OK I have extended my answer with a clarification, hope this lets you understand better! – Maciej Jureczko Sep 10 '17 at 11:53
Try to explicitly specify that you want to fetch all the remote branches:
git fetch origin '+refs/heads/*:refs/heads/*'
To make this a permanent setting do:
git config remote.origin.fetch '+refs/heads/*:refs/heads/*'
Local copy of a branch is only created when you actually check it out. So if you have remotes/origin/branchX
then to have local branchX
you would want to git checkout branchX

- 2,235
- 2
- 18
- 28
-
This will update the branches lists, or also will update the files I have locally? – Dimitrios Markopoulos Sep 10 '17 at 11:49
-
This will fetch all the remote branches, making it possible to check one of them out. Local files/work tree/index won't change. – Zloj Sep 10 '17 at 11:50