I've been working on a project.
I ended up having several errors start happening on me. Thinking that I did something stupid, I wanted to check a previous commit.
So I first did this:
git add .
git commit -am 'half baked code'
I did not push it up (since I wasn't sure if I broke anything).
I then did:
git checkout xdfsfsfs
grabbing a previous commit where I know everything worked.
I'm not trying to get back to my unpushed local commit.
git reset --hard
seems to bring me back to the latest commit on github, but not to the local commit.
git log doesn't show my commit
Is there anyway for me to recover the local commit? Or do I just need to re-code it? :)
You're looking for git reflog
This shows all actions undertaken in git even if not saved.
To fix this you're going to want to do
git reflog
Find the sha of the commit you made previously
git checkout SHA
git checkout -b mycommit
now you can merge this into your master or wherever it needs to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With