Photo by Markus Winkler on Unsplash
Deleting a commit with Git
๐ก If you want to delete a commit you can do an interactive rebase.
1.- You can do an interactive rebase with git rebase -i HEAD~
command. In HEAD~
you should indicate the numbers of the backward commit that you want to see.
git rebase -i HEAD~3
2.- Change pick
by drop
in the commit that you want to delete. For exit press ESC + Shift + :
and write :wq
to save changes.
drop 5cf29c5 Update README file with descripcions
3.- Use git log
command to see historical changes.
git log
4.- Force push
with the command:
git push origin main -f
Reference:
ย