How can I combine 2 commits into 1 in git in a branch?
This question already has an answer here:
You can use interactive rebase to combine two commits. You need to use the squash
option on the second one.
Start with:
git rebase -i HEAD~2
in the editor, you will see 2 lines in this order:
pick E's SHA-1
pick H's SHA-1
replace it with
pick E's SHA-1
squash H's SHA-1
Then close the editor. Git will pick E, then combine H to it.
You will be prompted for a new, combined commit message. Close that editor when finished and the rebase will finish by itself.
链接地址: http://www.djcxy.com/p/23446.html上一篇: Git将两个提交消息合并为一条消息