Undo Last Commit
Related: Uncommit Last Commit
Since there's a no direct meaning of 'undo' for a commit in Git, I'll use the term here to mean reverting changes done in previous commit by a new commit.
To revert the changes done in the last commit by a new commit:
git revert HEAD
Alternatively, to undo changes of only some files of the last commit, the following command would restore the specified files in the working directory back to the the specified commit:
git restore --source=HEAD^ files/to/undo
Then, a commit would commit the changes to the tree.
Source: git restore, Git - git-restore Documentation
Backlinks