GIT won't pull latest changes from remote
Solution 1
Not sure if this is the correct etiquette but I was able to resolve myself even though @VonC and @AnimiVulpis we helping out.
Using git branch -a -vv
showed that both local and remote branches were pointing to the same commit, but that commit was wrong (that commit was from 8 months ago).
I cloned the repository into a new folder, logged into Bitbucket to get the latest commit hash and used git reset --hard [commit hash]
to point the HEAD to the correct commit.
Now everything seems to be working fine (although in a different directory lol). I'm not sure how the remote branch ended up pointing to that commit, but glad the issue is resolved.
Thanks to both @VonC and @AnimiVulpis for taking time to help.
Solution 2
From your output, the local branches and remote tracking branches refer to the same commits, and are therefore up-to-date.
Try a git fetch
to confirm: it will update the remote tracking branches for all branches.
Then a git branch -avv
will show if there is any difference.
And a git branch -f mybranch origin/mybranch
(or git checkout -B mybranch origin/mybranch
) would be enough to reset it.
John Tiggernaught
Updated on June 08, 2022Comments
-
John Tiggernaught almost 2 years
Somehow my local branch is stuck 8 months behind my remote branch.
When I do
git pull origin [my branch name]
it saysAlready up to date
.I tried
git fetch origin [my branch name]
thengit reset --hard FETCH_HEAD
(found here) but my local copy is still pointing to the super old commit.I've also tried resetting to the specific by using
git checkout 1d5d525
(found here) but it says:error: pathspec '1d5d525' did not match any file(s) known to git.
but that commit is 100% in the remote branch because I can see it in BitBucket.The only thing I can think of that I've done any differently was that yesterday I worked on a different machine (my OSX laptop, rather than my Win10 desktop) but that doesn't explain why it's 8 months behind.
If any gurus could give me some guidance, that would be awesome.
NOTE: I can commit more changes from my laptop and they show up on my branch in BitBucket, but still no luck.
NOTE: I'm the only person that works on this branch in case that info is important.
Thanks!
EDIT:
Here is the output for
git branch -vv
andgit remote - v
as requested.$ git branch -vv ImageEdit 39b733c Image editing tweaks Widgets cce09e8 Merge Globals + Widgets to use the same functionality / DB table * john 11798f3 [origin/john] Finished PDF Header. Waiting for feedback... master cce09e8 Merge Globals + Widgets to use the same functionality / DB table $ git remote - v origin [email protected]:johnt/website.git (fetch) origin [email protected]:johnt/website.git (push)
NOTE: I'll point out that the master branch also seems to be way behind the remote based on the above commit message.
EDIT 2:
Here is the output for
git branch -a -vv
$ git branch -a -vv ImageEdit 39b733c Image editing tweaks Widgets cce09e8 Merge Globals + Widgets to use the same functionality / DB table * john 11798f3 [origin/john] Finished PDF Header. Waaiting for feedback... master cce09e8 Merge Globals + Widgets to use the same functionality / DB table remotes/origin/ImageEdit 39b733c Image editing tweaks remotes/origin/Widgets cce09e8 Merge Globals + Widgets to use the same functionality / DB table remotes/origin/glenn 0548f0d Changed Create a Lifeshare Page to Create a Lifeshare remotes/origin/john 11798f3 Finished PDF Header. Waiting for feedback... remotes/origin/master cce09e8 Merge Globals + Widgets to use the same functionality / DB table
-
VonC over 7 yearsA fetch would have been enough.
-
John Tiggernaught over 7 years@VonC I did
git fetch --all
but that still made it point to the wrong commit. I guess I should have donegit reset --hard [commit hash]
to save the trouble of doing the clone, but from memory, it displayed an error when trying to do that. Oh well, it seems the issue is resolved. -
VonC over 7 yearsYes, that was my answer: fetch + reset