Quantcast
Viewing latest article 7
Browse Latest Browse All 11

Remove your last git commit from a local repository.

Yeah, we’ve all been there. Committing to master when you wanted to commit to a freshly made branch. So the question is, how do you get rid of these nasty commits you’ve made?

Well, the answer is rather short, but it can be very handy to know. Here it goes:

git reset --soft HEAD~1

Where especially the --soft is cool since that keeps the changes you made to your files, even after the reset.

One thing to keep in mind: If you’ve pushed your changes, this doesn’t work, then you need to use the --hard option.

Happy gitting!


Viewing latest article 7
Browse Latest Browse All 11

Trending Articles