Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git status says up-to-date with remote even though it's not

Tags:

git

git-status

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?

like image 339
Jake Wilson Avatar asked Apr 06 '15 21:04

Jake Wilson


People also ask

Why does git status says up to date but not?

This status message is OK. We are up-to-date, there is nothing to commit, but there is still an untracked file. Since this file should not belong in git, this status shows a good git repo with all updates available to the instructor and the partner.

Why does git pull says already up to date?

The message “Already up-to-date” means that all the changes from the branch you're trying to merge have already been merged to the branch you're currently on. More specifically it means that the branch you're trying to merge is a parent of your current branch.

How do you check if git is up to date with remote?

To check if you're up-to-date with GitHub run git fetch origin before git status and you'll know you're up-to-date.

Does git check remote status?

If your current local branch is linked to a remote branch, then git status will tell you if your local branch is behind or ahead by any commits.


1 Answers

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.

like image 73
phts Avatar answered Sep 24 '22 06:09

phts