On one machine git log show it does not get the latest commits from remote repo (after run git pull)
git log --oneline -n 3 origin/develop
5a8e6eb xxx
7547c8a xxx
53294b6 xxx
On another machine, the correct one, it gets the latest commit 4b45d4b
git log --oneline -n 4 origin/develop
4b45d4b (origin/gq_dev, origin/develop) xxx
5a8e6eb (tag: dev_12) xxx
7547c8a xxx
53294b6 (origin/zsf) xxx
What strange on the problematic machine is that, my guy told my he actually used git pull origin pull
to get the latest commit 4b45d4b from origin. So when run git status it then shew "Your branch is ahead of 'origin/develop' by 1 commit."
git status
# On branch develop
# Your branch is ahead of 'origin/develop' by 1 commit.
...
git show
commit 4b45d4bfff7c54169fea7343c5b4f020be556d0a
So what did that happen and how do I fix it?
------- update -----------
I accidentally fixed it without knowing why, so I added write permission to anyone to .git/logs/refs/remotes/origin/develop file
Originally it was
ls .git/logs/refs/remotes/origin/develop
-rw-rw-r-- 1 gongqiang gongqiang 2103 Jan 30 19:07 develop
After adding write permission and run git pull again the problem fixed! But I still don't know why.
----- update 2 ------
The answer I got from VonC cast some light on the issue but there are still questions left unanswered.
- ls .git/logs/refs/remotes/origin/develop shew only the guy gongqiang had write permission originally (b/c it was him who run git checkout the develop branch). It was also him that run git pull to get latest commit 4b45d4b.
- After I run git status said "Your branch is ahead of 'origin/develop' by 1 commit" I checked this file. It did NOT record latest pull. But since it was this guy own the file and run that git pull. Why git failed to record it?
- I change this file to write permission to anyone and run git pull again to fix it. But I really doubt this is the "correct" fix.
Another question raised from here is since this is a branch that more one person will git pull (the integration branch to do test). Is it better to use sudo git pull
or change the write permission let other run git pull
without sudo
---- update 3 -----
I accepted VonC answer and the link he provided in commits https://serverfault.com/questions/26954/how-do-i-share-a-git-repository-with-multiple-users-on-a-machine/27040#27040 is useful.
But I also needed to point out that it is probably impossible (or not worth the effort) to find out why the guy who owned .git/logs/refs/remotes/origin/develop
failed to let git update it when he run git pull.
So a lesson I learned here is when finding git status
said something strange, check with .git/logs/refs/remotes/origin/develop/branch
to verify