I am using git reset to navigate backward in my git tree; however, except the time that I use --hard option, my files do not get back to their earlier versions. As an example I made a file called f1.txt and in every commit, I added a character to it, but when I use git reset --mixed or git reset --soft commands, they do not change the content of f1.txt and all the characters are there (although when I use git log, I see that the HEAD has moved back).
Making "git reset" effective without using "--hard" option
107 Views Asked by amiref At
2
You cannot use
git resetto navigate through your tree.git resetwill reset the "stage" (what is committed when yougit commit). So if you dogit addand want to undo that, you usegit reset.If you do
git reset --hard HEADit will also reset the file to the status ofHEAD.To navigate through the tree, you need to use
git checkout <branch/commit>. It you do not want to checkout the commit, but just get the one file from a previous commit, you can dogit checkout <branch/commit> -- path/to/file.Checkout the docs: