There are certain scenarios where you need to unstage local Git commit changes. As everything with Git, there are multiple angles from which you can approach almost anything.
Prerequisites
- Git
Solution(s)
Unstage commit but keep changes
git reset --soft HEAD
Unstage commit and get rid of any changes
git reset --hard HEAD
Note(s): HEAD
means that you will unstage your last commit. If that’s not the case, replace HEAD
with the preferred commit ID.
Conclusion
Related post: Unstaging files in Git.
To find more neat Git commands and hacks, simply browse the Git category. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.