Understand the basics of version control
Hey, I’m sure I’m not in this case. You know you make your git add and then your git commit -m "..." But oh no I forgot a file… Well rather than create a second commit, why not just undo the previous one and recreate it?
Here’s a git alias I use every day:
alias.undo=reset --soft HEAD^
Here’s how to create it:
git config --global alias.undo 'reset --soft HEAD^'
Tips : If you have already pushed your commit into your PR, you will have to use git push -f .
Thanks for reading.
How to undo a commit
Hey, I’m sure I’m not in this case. You know you make your git add and then your git commit -m "..." But oh no I forgot a file… Well rather than create a second commit, why not just undo the previous one and recreate it?
Here’s a git alias I use every day:
alias.undo=reset --soft HEAD^
Here’s how to create it:
git config --global alias.undo 'reset --soft HEAD^'
Tips : If you have already pushed your commit into your PR, you will have to use git push -f .
Thanks for reading.
Top comments (0)