I’m trying to get the previous version of a file like this:
git checkout <git-hash>
After this, I see that the file on my hd is the previous version. How can I push
this version to the server??? I tried the following:
git push ab master
but all I get is
Everything up-to-date
What am I doing wrong?
When i do
git checkout 123456 -- src/test.c
git commit -m "Bringing back test.c from commit 123456"
I get
Not currentyly on any branch
123456 is hash
I’m assuming that 123456 is the name of an old commit, not the name of a file – it’s not clear from the question, as Ben Hocking points out.
When you push, you push a complete commit (which defines the complete state of a tree) rather than individual files. The
git push ab mastercommand is the same asgit push ab master:master, which means “updatemasteron the remoteabwith my version ofmaster“. The error “Everything up-to-date” is telling you that all of the history of yourmasterbranch is already contained in the remotemasterbranch.Instead, you’ll need to create a new commit with the old version of that file instead. You can do this with: