You should understand the implications of rewriting history if you has already been published. It's almost always a bad idea to use -force prefer -force-with-lease instead, and as noted in the git manual: To remove (not revert) a commit that has been pushed to the server, rewriting history with git push origin main -force is necessary. If you do not need to edit the message, you could use the -C option.Īlternatively, to edit the previous commit (or just its commit message), commit -amend will add changes within the current index to the previous commit. git/ORIG_HEAD commit with -c ORIG_HEAD will open an editor, which initially contains the log message from the old commit and allows you to edit it. Commit the changes, reusing the old commit message.git add anything that you want to include in your new commit.Make corrections to working tree files. You'll need to add them again before you can commit them again). It will undo your last commit while leaving your working tree (the state of your files on disk) untouched. git reset is the command responsible for the undo.Undo a commit & redo $ git commit -m "Something terribly misguided" # (0: Your Accident)
0 Comments
Leave a Reply. |