Search code examples
gitgit-pullgit-fetch

Git pull shows "already up to date" but they're wrong


DISCLAIMER : There's already a post that already addresses this issue but sadly the author did not find any definite answer.

Here's my issue : git pull shows "already-up-to-date" but they're wrong

👉 For a quick 2-min video explaining the issue just here.

👉 For written explanation, read below.

Here's the sequence of events :

  • On my local machine / locally, I've got two branches : main and F01
  • I added a few commits to F01
  • From F01, I git push the commits to gitHub
  • On my remote repo, I now have two branches too : origin/main and origin/F01
  • Created a PR to merge origin/F01 -> origin/main
  • PR merging went successfully well ✅
  • Now I want to git pull from main (local) the commits recently added to origin/main
  • git pull : ❌ "Already up to date"

I already tried:

  • git fetch : ❌ nothing.
  • git diff main..origin/main : ❌ nothing, no changes detected
  • git diff main..F01 : there are changes ✅
  • git diff main..origin/F01 : there are changes ✅

Any ideas as to why origin/main can't be updated and sync with the real state of origin/main?


Solution

  • With the help of a mate who advised me to use gitHub Desktop, I've found the possible reason of the issue :

    default branch is wrong

    Instead of having main or origin/main as my default branch, for some reason (some command I may have accidentally performed), the F02 became the default branch. And I must have created F02 from origin/main. So I suppose @Nikhil was probably right.

    Which was very weird because when performing a git branch I could only see the following (and no F02 available) :

    git branch no F02

    Solution I've found: I've locally merged local/F01 -> local/main and right after that I tried to git reset --hard to remove all the commits I had just added.

    As a result : when doing git diff main..origin/main, now it worked! ✅ I could see the changes on origin/main that were not on local/main :)

    So I went back to my post to update my post and share my investigation and solution and found your two posts @larsks and @Nikhil.

    @Nikhil : sadly I saw your post only after but I bet it would have made it worked cause it looks like the HEAD was detached from main or origin/main

    @larsks : I had already performed your command and indeed : F01 did show changes ✅ but main/origin did not show any new commits 😳 (for some reason).

    Thank you very much for your help guys and for responding so quickly!