3

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 Answers2

5

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.

Maciej Jureczko
  • 1,560
  • 6
  • 19
  • 23
1

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

Zloj
  • 2,235
  • 2
  • 18
  • 28