28

I am using Git to cooperate with other users, but today I cannot get the latest change on some files using "git pull", and I cannot see the changes in "git log".

What could be the issue?

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
cao lei
  • 741
  • 1
  • 8
  • 19
  • 1
    are you sure they pushed correctly their work? – Jepessen Dec 14 '13 at 10:08
  • It seems nothing is there to get the updates. Are you sure the files are committed correctly by other user and in the same repository? No Logs gives a doubt in this direction. – Aditya Dec 14 '13 at 10:11
  • Are you sure you sub ordinates have pushed to the branch you are trying to pull ? – Balram Tiwari Dec 14 '13 at 10:12
  • I'm having the same issue (I'm the only one at work with this issue). It's driving me batty! For the past few days I've been doing manual merges because pulls just aren't happening. But the manual merge causes all sorts of warnings to go off, which scares the entire team. – SMBiggs Mar 02 '16 at 17:58
  • What is your error message or what is your ouput of the git pull command? – Strubbl Jun 18 '20 at 19:01
  • This happened to me more than once in git. It's very weird. I've used hg for more then 15 years and it's never happened. – Iasmini Gomes Jul 02 '20 at 00:28

10 Answers10

34

what worked for me is ,

  1. remove .git folder
  2. copy .git from other repo
  3. now git checkout

Before Removing , You can try

git fetch --all 
git reset --hard origin/master

ALL THE BEST

ganesh
  • 1,377
  • 11
  • 14
  • 1
    The last two steps (fetch and reset) worked for me. Btw, "copy .git from other repo" shouldn't work, as each .git contains info specific to the repo it belongs to. – Gaurav Singh Jun 12 '19 at 06:44
  • 1
    The last command "git reset --hard origin/master" worked for me. – user85 Aug 12 '20 at 11:20
  • 1
    it worked for me the last 2 commands git fetch --all git reset --hard origin/master :) – chiperortiz Aug 25 '20 at 15:08
16

What worked for me,

git reset --hard origin/master

It showed me that some file names were too long for git to pull them from my repo and hence the mismatch and incorrect builds.

So I ran following to fix and did a hard reset again.

git config --system core.longpaths true

Thankfully it worked.

Dish
  • 869
  • 9
  • 28
6

In my case the issue was me having an index.lock file in my .git folder. I removed that, and pull worked.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Alwyn Schoeman
  • 407
  • 6
  • 10
5

Check your current branch.

git status
git branch

If you are not in a branch, you are in a detached HEAD mode and git pull wouldn't merge anything.

git log --all --branches

That git log will help make sure you see if there are any new commits on fetched branches (that is, the remote tracking branches).
I use that git log alias to display those commits as a graph.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
4

You could have an unfinished merge that prevents the pull. Check if you have a commit in progress.

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
1

I just wanted to add another case where this could happen. I was using a sparse checkout. For some reason I had a directory in my working tree that I thought was included in the sparse checkout (I thought it was listed in .git/info/sparse-checkout) but wasn't (I had removed it from .git/info/sparse-checkout for some reason I now forget.) So it was just being ignored by pull or checkout or reset or any other commands. It was very confusing until I started replicating the sparse checkout configuration in a new, fresh clone and realized the error.

This would only happen to you if you are using a sparse checkout. If you are not using a sparse checkout, it couldn't happen. (Check git config to see if sparseCheckout is enabled, and check for the existence of .git/info/sparse-checkout, but you would know if you were doing this since I think it has to be set up manually by the user anyway.) (Google it if you're curious what it is-- its just a simple mechanism to omit files and directories from a checkout that would otherwise be tracked/pulled/fetched etc.)

Reed Hedges
  • 1,556
  • 2
  • 14
  • 17
0

There are 2 possible sceanrios:
1. If you have any account in Bitbucket, gitlab and etc.
You might have to synchronise with your fork directory first and then perform git pull on your local branch. Basically you have to rebase your fork copy to get in sync with remote master and perform git pull in your local copy.
2. Just try to rebase your local work copy to be in sync with remote master.

Vinod Kumar
  • 396
  • 3
  • 11
0

git reset --hard origin/master

works for me but you have to go inside the folder and then use this command not only on the parent folder.

0

hope my comment will be usefull for someonle)) i had this kind of issue. iam using laravel on ubuntu, so i solved it by reseting opcache and restarting queue worker.

fariqa
  • 11
  • 2
0

for me it was commits that I made locally. These commits modify something I want to pull. So git pull doesn't get the file from origin

loser8
  • 130
  • 10