uncommit my last commit in Git ?

Just use this ( it will keep the working tree with its changes but undo the last commit ).

git reset --soft HEAD^

If you want to undo the act of committing and everything you'd staged, but leave the work tree (your files intact):

git reset HEAD^

And if you actually want to completely undo it, throwing away all uncommitted changes, resetting everything to the previous commit (as the original question asked):

git reset --hard HEAD^

HEAD^ not HEAD. HEAD refers to the current commit - generally, the tip of the currently checked-out branch. The ^ is a notation which can be attached to any commit specifier, and means "the commit before". So, HEAD^ is the commit before the current one, just as master^ is the commit before the tip of the master branch.

We talked about how to undo the last git commit. See you next post. If you find this post useful, share it with your friends and colleague on social media or via EMail. If you want to get new posts, make sure to subscribe to Value In Brief by Email.