Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT won't pull latest changes from remote

Tags:

git

bitbucket

Somehow my local branch is stuck 8 months behind my remote branch.

When I do git pull origin [my branch name] it says Already up to date.

I tried git fetch origin [my branch name] then git 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 and git 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
like image 808
John Tiggernaught Avatar asked Aug 19 '16 04:08

John Tiggernaught


2 Answers

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.

like image 84
John Tiggernaught Avatar answered Nov 08 '22 08:11

John Tiggernaught


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.

like image 42
VonC Avatar answered Nov 08 '22 09:11

VonC