Reputation: 3114
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?
Upvotes: 21
Views: 47945
Reputation: 20520
So there are some unpopular realities:
Git does have errors that place it into unknowable states. Some of these states are recoverable, some are not.
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.
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".
The Git experience is convoluted and opaque. For example, contributing to a project usually requires this little dance:
~/.gitconfig
and project .git/config
.Given that:
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
.
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.
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.
Give up; chalk it up the cost of a proprietary system. Try deleting and reloading things.
git clone
a new copy from the main open source project.There is a significant cost to using the git/Github lifecycle.
Upvotes: 0
Reputation: 93
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.
Upvotes: 0
Reputation: 109
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.
Upvotes: 4
Reputation: 2497
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.
Upvotes: 2
Reputation: 199
I used Team Explorer from my Visual Studio application and was able to Sync, Fetch, and Pull. That finally worked.
Upvotes: 1
Reputation: 1329
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.
Upvotes: 24
Reputation: 1326376
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.
Upvotes: 3