Git pull not pulling the latest revision
Asked Answered
A

7

20

We use Github for source control in our organization. Multiple developers continuously merge their changes to remote source repository. In my case I cloned the repository when two weeks back and there were multiple merges after that. Now I am trying to get the latest revision of the code using.

git pull origin master

I for sure know that there were multiple merges that have gone in since last time I cloned but pull command tells me that its already up to date. Am I missing anything here?

Andersonandert answered 12/11, 2012 at 3:42 Comment(4)
Is git fetch showing anything?Filibeg
@Filibeg It didn't give me anything .. it just asked for credentialsAndersonandert
try a git reset --hard origin master , may be your local head is not on the good indexRms
git reset --hard origin master gives fatal: Cannot do hard reset with paths..Insistence
A
22
git reset --hard HEAD~20 # some large number
git pull origin master

This fixed my problem with an un-pullable update. The idea is to push HEAD back far enough to clear up any confusion for git. Then make the desired pull.

Aucoin answered 3/11, 2016 at 19:19 Comment(1)
How about resolving this?Aucoin
D
5

For me the solution was:

from the current branch I executed git pull origin ${current-branch-name} in my specific case the complete command was:

From develop branch: git pull origin develop

The git reset --hard HEAD and git pull origin HEAD commands do not work for me.

Dilorenzo answered 11/1, 2023 at 19:50 Comment(3)
This solved the issue for me where the reset did not. Thanks for that.Disinclination
This worked for me! I was having issues in one of my branches where I cannot pull the latest commit. I switched to a different branch and pulled using the suggested code above and it worked!Iorgos
This worked for me whereas the other suggestions did not. Wondering what might have caused this scenario, as this kept happening lately. I suspect it has to do with what other people are doing at the repository (minimal experience and communication)Ditty
V
3

One explanation would be that the latest commits have been done on another branch, as explained in "Git pull from my public repository not working".

The other possibility is for you to be in a detached HEAD mode.
That would make any git pull "up-to-date" since you are in any branch.

Vaientina answered 12/11, 2012 at 7:21 Comment(0)
H
1

I used Team Explorer from my Visual Studio application and was able to Sync, Fetch, and Pull. That finally worked.

Haematocele answered 8/10, 2018 at 0:54 Comment(0)
N
1

For me, nothing seemed to work and I had to clone the repository from GitHub again. As a last resort that might be an option.

Nickynico answered 1/2, 2022 at 16:41 Comment(1)
If all other things fail, you can avoid needing to clone the entire repo by going to a different branch, deleting the problematic one, running git fetch and then changing back to it.Disinclination
I
0

I used git status to show all the current local changes to files. I then removed them by using the command "git restore <file>...". After removing all I simply used git pull origin/master and it fixed the issue.

Infraction answered 1/5 at 6:24 Comment(0)
I
0

So there are some unpopular realities:

  1. Git does have errors that place it into unknowable states. Some of these states are recoverable, some are not.

  2. Git has options that place you into obscure states, such as detaching your head, applying commits to different branches locally and remotely. These are usually recoverable with more arcane tricks.

  3. Git is a program with an open source license. GitHub is a proprietary website owned by MicroSoft. One will expect some bundling issues, meaning GitHub will work differently on Microsoft Windows or other Microsoft products. The goal of GitHub is not "best developer experience".

  4. The Git experience is convoluted and opaque. For example, contributing to a project usually requires this little dance:

  • making a fork of the project,
  • clone your fork of the project,
  • making your own branch in that project,
  • write the changes,
  • commit the changes locally,
  • push the changes to your branch of the your repository
  • create a pull request in the main project
  • switch your local branch to prevent future changes from automatically being added to the pull request
  1. You will need to check the configurations of your ~/.gitconfig and project .git/config.

Given that:

  1. Check that you are on the main branch, usually named master or main and that your head is not detached. Do this with git status.

  2. Check that your configuration even knows about the repository you are trying to pull from, instead of just your own fork of the repository. Do this with "cat <project_directory>.git/config". You may be trying to pull from the open source project, but only pulling from your own, now out of date, fork of the repository.

  3. Try one or two tricks for a broken repository. As @joel3000 suggests, move your head (lastest commit you see) back in time to try to force commits to be reloaded and reapplied. That is done as git reset --hard HEAD~90 && git pull origin HEAD. Maybe it works, maybe it doesn't.

  4. Give up; chalk it up the cost of a proprietary system. Try deleting and reloading things.

  • First, save any work locally to a new directory
  • Second, delete your local repository and git clone a new copy from the main open source project.
  • Third, if that doesn't work, delete your GitHub fork and recreate it.

There is a significant cost to using the git/Github lifecycle.

Insistence answered 14/7 at 19:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.