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 lastest changes. And I have only one branch named master and one remote server named origin.
This is what git displays when running ls-remote, I'm not sure whether it helps
$ git ls-remote origin
$ git ls-remote .
You would not be working with a detached head by any chance ?
indicating that your latest commit is not a branch head.
$ git log -1 # note the SHA-1 of latest commit $ git checkout master # reset your branch head to your previously detached commit $ git reset --hard <commit-id>
As mentioned in the
git checkout man page (emphasis mine):
It is sometimes useful to be able to checkout a commit that is not at the tip of one of your branches.
The most obvious example is to check out the commit at a tagged official release point, like this:
$ git checkout v2.6.18
Earlier versions of git did not allow this and asked you to create a temporary branch using the
-boption, but starting from version 1.5.0, the above command detaches your
HEADfrom the current branch and directly points at the commit named by the tag (
v2.6.18in the example above).
You can use all git commands while in this state.
You can use
git reset --hard $othercommitto further move around, for example.
You can make changes and create a new commit on top of a detached HEAD.
You can even create a merge by using
git merge $othercommit.
The state you are in while your HEAD is detached is not recorded by any branch (which is natural --- you are not on any branch).
What this means is that you can discard your temporary commits and merges by switching back to an existing branch (e.g.
git checkout master), and a later
git gcwould garbage-collect them.
If you did this by mistake, you can ask the reflog for HEAD where you were, e.g.
$ git log -g -2 HEAD