I got in a bit of git trouble today. I had a branch where I had been working on for a while. For some reason when I wanted to merge this branch back into master it did not add the changes I had made in that branch. At this time of distress Google is always at hand to help and sometimes cause more problem.
In the time I was trying to resolve my little predicament I learned a few new commands.
First on the list I tried was
git reset –hard HEAD~1
this resets the current branch to master -1 commit. you can change the number to whatever you want to go back as many commits if you want.
I also used this
git reset –hard branchname
that one resets your current branch to the branch you named.
and then I learned
which will give you a nice list of what you did.
And yes I made a mess of things.
And finaly you can do.
git reset –hard a8bb565
which will let you back to any of the commits by Id, you can see the id’s of each commit in the reflog above.
So screwing up is educational sometimes.