Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
2 views
in DevOps and Agile by (29.3k points)

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 the 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.

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

1 Answer

+2 votes
by (19.4k points)
edited by

Check whether you are on HEAD or Detached HEAD.

This error basically occurs when the HEAD is detached so you need to reset and make the branch as a HEAD for that you could do:

$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>

For reference check out this: https://git-scm.com/docs/git-checkout

Please find this link where we have a video which says about git lifecycle:

Also, you can read the Git Tutorial to briefly understand the concept. 

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...