Or, the merger of the subsequent commit and the previous one can also be carried out.
If you want to change
commit message
Withgit commit -amend
.If you want to add some content, don’t move the previous one.
commit
(just callcommit-1
, then modify, and then submit a newcommit
(commit-2
)。 Thengit rebase -i HEAD~~
, the following will appear:pick commit-1-hash commit-1-message pick commit-2-hash commit-2-message
Will the second
pick
Change tosquash
Save to exit, appear:# first commit message: commit-1-message # second commit message: commit-2-message
Delete these things and change them to what you want.
commit message
Save and exit.Then you can
git log
Check it out, twocommit
Has been merged into a new onecommit
Here we go.You can refer to:
5. submit by rebase -i convergence===
BTW, if you last
commit
It has been pushed to the remote branch, and someone in this branch is cooperating with you, so it is better not to modify it. Because after you modify it, it is out of sync with the remote branch, so you need togit push -f origin your-local-branch
To submit, which may cause other people’s branches to be out of sync with the remote.