0

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)

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • 1
    Are you sure the new work is available in the repository that is your `origin`? – j6t Nov 28 '22 at 06:46
  • https://stackoverflow.com/a/25941875/6330106 – ElpieKay Nov 28 '22 at 06:46
  • Fetching does _not_ mess up with your local branches. If you want to see your local `thebranch` branch _move_, I guess you will have to either merge/rebase after fetching _or_ do a `git pull` so that it does fetch-then-rebase/merge in a single shot. – eftshift0 Nov 28 '22 at 08:19

2 Answers2

0

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

Yehya
  • 506
  • 1
  • 5
  • 16
0

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>.

LeGEC
  • 46,477
  • 5
  • 57
  • 104