Or, the merger of the subsequent commit and the previous one can also be carried out.
If you want to change
git commit -amend.
If you want to add some content, don’t move the previous one.
commit-1, then modify, and then submit a new
git rebase -i HEAD~~, the following will appear:
pick commit-1-hash commit-1-message pick commit-2-hash commit-2-message
Will the second
squashSave 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 messageSave and exit.
Then you can
git logCheck it out, two
commitHas been merged into a new one
commitHere we go.
You can refer to:
5. submit by rebase -i convergence
BTW, if you last
commitIt 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 to
git push -f origin your-local-branchTo submit, which may cause other people’s branches to be out of sync with the remote.