git rebase merge multiple commits

Mainly refer to the following article
https://juejin.cn/post/6844903600976576519

Here we use the command:

git rebase -i  [startpoint]  [endpoint]

Among them, -i means –interactive, that is, an interactive interface pops up for the user to edit and complete the merge operation. [startpoint] [endpoint] specifies an editing interval. If you do not specify [endpoint], the end of the interval is the current by default The commit pointed to by the branch HEAD ( note: this interval specifies an interval that opens before and closes ). After viewing the log, we run the following command:

git rebase -i 36224db

The commit here refers to the previous commit of the commit we want to merge
or

git rebase -i HEAD~3 

According to our needs, we edit the commit content as follows:

            pick d2cf1f9 fix: 第一次提交
            s 47971f6 fix: 第二次提交
            s fb28c8d fix: 第三次提交

The above means to merge the second and third submissions into the first submission.
Then after wq save and exit, the comment modification interface is displayed, and wq is also saved.
You can see that all commits have been combined into one.

Guess you like

Origin blog.csdn.net/qq_42648305/article/details/112355744