Using git for version control is undoubtedly very convenient. You can modify the code at will. Submitting code is what developers do every day. The refreshing submission record is refreshing. In some scenarios, the development will generate some trivial submission records, such as the submission of debugging CI tools and the submission of sporadic bug modifications. These submission records should belong to one record. In this case, the historical submission can be merged through ‘git rebase’.
Merge history submission
I used to use ‘git commit — amend — no edit’ to merge submission records. It will merge the latest submission record with the previous submission record. The applicable scenarios are limited.
In the scenario in the figure above, the submission history contains multiple submissions of debug CIS, and the submission of debug CIS is not the latest submission. In this case, the purpose of merging historical submissions can be achieved through the ‘git rebase’ command. Type ‘git rebase -i head ~ 5′ to enter the interactive page of rebase. In this scenario, I want to view the first 5 submissions of the current head, so it is’ head ~ 5 ‘. In addition, the ` git rebase – I — root ‘command can select the range for all submitted records.
According to the information in commands, merge history submission should be marked with’s’, which will merge the marked submission record to the previous submission record.
Modify record commit message
The above figure shows the effect of merging historical submission records. The ‘git rebase’ command integrates trivial submission records into one. The submission records look much cleaner. Take a closer look. There is an error in the commit message of the debugging CI tool. You should use the chord type. At this time, you can continue to use the ‘git rebase’ command to modify the commit message. According to the commands just now, the “R” flag should be used in the scene of modifying the record commit message. It will only modify the commit message and will not affect the submitted content. Finally, the modified results are shown in the figure below.