How do I undo the most recent local commits in Git?
问题 I accidentally committed the wrong files to Git, but I haven't pushed the commit to the server yet. How can I undo those commits from the local repository? 回答1: Undo a commit and redo $ git commit -m "Something terribly misguided" # (1) $ git reset HEAD~ # (2) << edit files as necessary >> # (3) $ git add ... # (4) $ git commit -c ORIG_HEAD # (5) This is what you want to undo. This does nothing to your working tree (the state of your files on disk), but undoes the commit and leaves the