Answers for "How to undo the most recent local commits in Git"

0

How to undo the most recent local commits in Git

$ git commit -m "Your wrong commit" 		   # (0: Your Accident)
$ git reset HEAD~                              # (1)
[ edit files as necessary ]                    # (2)
$ git add .                                    # (3)
$ git commit -c ORIG_HEAD                      # (4)
// with -c ORIG_HEAD will open an editor, which initially contains the log message from the old commit and allows you to edit it. If you do not need to edit the message, you could use the -C option
Posted by: Guest on February-02-2022

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language