I created my code on local computer.
Once I pushed the code to git server.
git add -A
git commit -m "test"
git push -u ...
After that on the same branch I made lot of changes, and than did commit
git add -A
git commit -m "test"
The commit succeeded, but I instead of push I did
git checkout master
Then I realized I didn't push the code, so I did
git checkout mybranch
I realized again that the checkout I did was from the git server, and I didn't see code of mine, even I did commit.
I know that commit is kept on my local computer, but is my latest changes gone?
How can I restore the latest changes of mine?
Thank you in advanced.
You should be able to git switch
(better than git checkout
) your branch and see your code.
But if not, check git reflog
, and look for a recent commit SHA: try and git switch --detach <SHA>
to inspect that commit, making sure your changes are there.
The OP Eitan reports in the comments having succeeded, using git log --pretty
:
I found the date+time, and do checkout.
git reflog --pretty=format:"%H %an %ad"