I have looked through other questions on similar question.
But they seem to say the answer is git fetch --all
.
But in my case, it doesn't work.
This is what I have done for it.
> 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
also 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
Git fetch commands and optionsFetch all of the branches from the repository. This also downloads all of the required commits and files from the other repository. Same as the above command, but only fetch the specified branch.
1 Answer. git fetch --all and git pull -all will only track the remote branches and track local branches that track remote branches respectively. Run this command only if there are remote branches on the server which are untracked by your local branches. Thus, you can fetch all git branches.
git branch
only displays local branches.
git branch -r
will display remote branches, as you've seen for yourself.
git branch
*master
git branch -r
origin/master
origin/A
git fetch --all
will update the list you see when you type git branch -r
but it will not create the corresponding local branches.
What you want to do is checkout the branches. This will make a local copy of the remote branch and set the upstream to the remote.
git checkout -b mylocal origin/A
git branch
master
*mylocal
git branch -r
origin/master
origin/A
mylocal
in this case is origin/A
. The -b
parameter will create the branch if it doesn't exist. You could also just type: git checkout A
will will auto-name the new branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With