Quantcast
Channel: Mark P. Lindhout’s Flamepit » News
Viewing all articles
Browse latest Browse all 10

Remove your last git commit from a local repository.

$
0
0

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 all articles
Browse latest Browse all 10

Trending Articles