Reset your last commit in git

So, you committed a change in your local repo and then realized you had the wrong branch? This happens to me a lot and the command I found the most useful for this purpose is:

git reset --soft HEAD^

git reset

Run the above 2 commands and you will have your uncommitted files back. After that you can switch to the right branch and commit them again.

 

Tags: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>