We have a Git repository hosted on a shared network drive that multiple co-workers access. I'll call this the "central repository". Employees clone this repository to their local machines, make changes, and then push changes back up.
We've noticed that if someone pushes a change to the central repository, other employees' local Git repositories don't indicate that they are out of sync. git status
says
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
But it's clearly not up-to-date. There are changes on the remote, but Git isn't sensing them. You can do a git pull
and it immediately downloads the changes to your local repository even though it claimed it was already up-to-date.
Why is this happening? Is it because the central repository is hosted on a shared network drive? And maybe Git is for whatever reason not able to tell if it's out of sync? Using a GUI like Tower doesn't make a difference either. Even hitting "Refresh" in the GUI does not make any indication that it's out of sync. Also, the local master branch is tracking origin/master
.
Is there anything that can be done to fix this problem?
You have to call git fetch
to get updates from the remote repository to your local repository, but without changing your current branch position. After that, git status
will show proper results.