How to get the whole remote branch, "git fetch --all" doesn't work

I looked at other questions on a similar issue.

But they seem to say that the answer is git fetch --all .

But in my case, this does not work.

Here is what I did for this.

 > git branch * master > git branch -r origin/master origin/A > git fetch --all > git branch * master #still not updated > git fetch origin/A fatal: 'origin/A' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. > git fetch remotes/origin/A fatal: 'origin/A' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

And I also tried git pull --all , but the result is the same.

------------------- ------------------- Edit

 > git pull --all Already up-to-date. > git branch * master # I think it should show branch A also > git remote show origin HEAD branch: master Remote branches: A tracked master tracked 

------------------- ------------------- Edit

 > git pull origin A * branch A -> FETCH_HEAD Already up-to-date. > git branch * master # I think it should show barnch A also 
+6
source share
3 answers

git branch only local branches are displayed. git branch -r display the remote branches, as you saw yourself.

 git branch *master git branch -r origin/master origin/A 

git fetch --all update the list that you see when you type git branch -r , but it will not create the corresponding local branches.

What you want to do is check the branches. This will make a local copy of the remote branch and configure the upstream channel to the remote.

 git checkout -b mylocal origin/A git branch master *mylocal git branch -r origin/master origin/A 

mylocal in this case origin/A The -b switch to the new branch after it is created. You can also simply enter: git checkout A will automatically indicate a new branch.

+6
source

I think you are really looking for the git branch -a command. It will display all local and remote branches. Here is an example:

 # Only show local branches $ git branch * master develop # Only show remote branches $ git branch -r origin/HEAD -> origin/master origin/master origin/develop origin/foo # Show both local and remote branches $ git branch -a * master develop remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/develop remotes/origin/foo 

You will notice that there are all branches - the command will show both local and remote branches.

The hole foo goes only to the console, I do not have a local branch foo . To create a local foo branch, I would use the checkout command:

 # Create a local 'foo' branch from the remote one $ git checkout foo Branch foo set up to track remote branch foo from origin. Switched to a new branch 'foo' # Show both local and remote branches $ git branch -a * foo master develop remotes/origin/HEAD -> origin/master remotes/origin/master remotes/origin/develop remotes/origin/foo 

This should explain what you see locally.

+1
source

You also need to create the selected branch:

 git fetch --all && git checkout A 
0
source

All Articles