I have a remote gitosis server and a local git repository, and each time I make a big change in my code, I’ll push the changes to that server too.
But today I find that even though I have some local changes and commit to local repository, when running git push origin master it says ‘Everything up-to-date’, but when I use git clone to checkout files on the remote server, it doesn’t contain latest changes. And I have only one branch named “master” and one remote server named “origin”.
PS:
This is what git displays when running ls-remote, I’m not sure whether it helps
$ git ls-remote origin
df80d0c64b8e2c160d3d9b106b30aee9540b6ece HEAD
df80d0c64b8e2c160d3d9b106b30aee9540b6ece refs/heads/master
$ git ls-remote .
49c2cb46b9e798247898afdb079e76e40c9f77ea HEAD
df80d0c64b8e2c160d3d9b106b30aee9540b6ece refs/heads/master
df80d0c64b8e2c160d3d9b106b30aee9540b6ece refs/remotes/origin/master
3a04c3ea9b81252b0626b760f0a7766b81652c0c refs/tags/stage3
Are you working with a detached head by any chance?
As in:
indicating that your latest commit is not a branch head.
Warning: the following does a
git reset --hard: make sure to usegit stashfirst if you want to save your currently modified files.As mentioned in the
git checkoutman page (emphasis mine):While
git pushsays "everything up-to-date", you still can technically push a detached HEAD, as noted in the comments by Jonathan BennYou have to specify the destination branch, since the source is not a branch, and does not have an upstream target branch.