How to undo the most recent commit in Git? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to undo the most recent commit in Git?

30th May 2018, 8:46 PM
Ameer Abdulaziz
Ameer Abdulaziz - avatar
4 Answers
+ 6
How to undo the specific file from the most recent commit ? //find the previous version you want 1. git log --oneline <file> //checkout the specific file to that version 2. git checkout <commit-id> <file> //commit this change 3. git commit -m "Revert xxx file"
30th Jul 2018, 6:01 AM
Corey
Corey - avatar
+ 4
How to undo the specific file from the most recent commit ?
27th Jul 2018, 8:49 AM
Corey
Corey - avatar
+ 2
run: git reset HEAD~
30th May 2018, 8:51 PM
Ameer Abdulaziz
Ameer Abdulaziz - avatar
+ 1
Nice tip! Thank you
3rd Aug 2018, 6:23 AM
Ameer Abdulaziz
Ameer Abdulaziz - avatar