I have just a master branch in my git repo. I commited a change to my file yesterday night:
git add filename
git commit -m 'my message'
This morning I was making some more changes that later I wanted to revert (I had not added these changes to the index, they were only in my filesystem). I had a look here and used the following command:
git checkout path/to/file/filename
Now I noticed that my las commit was gone. I did a search and found this, but it refers to git revert.
If I do git log, my last commit shows up there, but the changes in the file are not. And if I do git status I get no changes showing and “nothing added to commit” message.
Why did it revert my last commit? How do I re-apply the commit?
Thanks in advance.
If for whatever reason your commit from yesterday has disappeared, the first place to look for said commit is in the reflog.
See for instance “how to undo a checkout in git?“
You can even “Query
git reflogfor all commits to a specific file“.