In the actual work scenario, there may be a file error in the process of submitting the code, and it needs to be resubmitted.
At this time, git commit --amend will come in handy
After git log, you can see the git history you have submitted before:
Next, enter wq in bash to exit the log status and execute:
git commit --amend
At this time, the following content will appear in bash:
Among them, second commit is the description of your last commit, and the following is the description information, which tells you the file information you submitted last time, etc., which can be ignored. Next, if you want to modify the description information. Type directly: i, and enter the input mode at this time, and it becomes like this:
You can use the up and down keys on the keyboard to go to the line where the description is located, and then modify it:
after the modification is completed, press the Esc key to exit the editing mode, type :wq, press Enter to exit and save the modification, and complete the submission. This is your git log and look at the commit log:
the commit description has been modified, and the original git version is gone.
But there is one thing to pay attention to, that is, this operation will change your original commit id.