Rajanand home page
Rajanand
Contact
Newsletter
Newsletter
Search...
Navigation
How to undo the last git commit in local repository?
Have a great day! 🤩
⌘K
How to undo the last git commit in local repository?
​
Undo last local commit but keep files changes.
Copy
git reset HEAD~1
All the changes committed in the last commit is present in the local repo.
Changes are not present in stage.
​
Undo last local commit and keep files changes in stage.
Copy
git reset --soft HEAD~1
No need to do
git add
again to add the changes to stage.
​
Undo last local commit and remove the changes from the repository.
Copy
git reset --hard HEAD~1
Git commit has been reversed.
The changes also removed from the local repository.
This option can be used before start using the branch. Just to make sure the branch is clean before making changes.
Assistant
Responses are generated using AI and may contain mistakes.