Home > Software engineering >  git fetch does not fetch a remote branch
git fetch does not fetch a remote branch

Time:11-28

Some time ago I git fetch a branch from a remote repo. Let's call it origin/thebranch So I had that and also my local thebranch I checkout a new branch on top of that and did my work Later I push that new branch into the remote after rebasing it to the latest master

The old origin/thebranch stayed in the same place after the rebase

So now I have been told there is new work in origin/thebranch so I did git fetch origin thebranch.

I got

From <remote repo url>
 * branch            thebranch -> FETCH_HEAD

and turns out nothing happened the branch (both remote and local) are in the same place and I did not get the latests commits of "the branch"

What can I do here?

(btw thebranch is written by a colleague so I am limited on what I can do I suppose)

CodePudding user response:

You need to use git pull command instead of git fetch, to merge remote changes to your local branch. Git fetch will not do the merge part.

git pull origin thebranch

CodePudding user response:

The sequence you describe matches what you should see if your local data is already up to date.


You can use git ls-remote to double check what state the branch is in on the remote server :

git ls-remote origin refs/heads/<thebranch>

Compare the sha you see here with git show -s origin/<thebranch>.

  •  Tags:  
  • git
  • Related