Use Git-Rebase merge multiple submissions

In the usual software development, we use a common repository for each team (here that is Git repository). Whenever there is a new demand, we will pull out a feature branch, then do development on this topic branch and submit personal code.

I have a habit: In order to ensure the security of the code, every day before work submitted to a public warehouse will own local repository code. Due to the development process every day for various reasons will submit the code several times to individual warehouses, thus leading to commute to submit code to the public warehouses, once submitted several records, this will be a variety of public warehouses have all incremental mess revision of history. In order to avoid causing too many submitted version control chaos, we usually recommend these submit merge into one.

Git on common commands, it is recommended to read Git commonly used commands

Use rebase merge commit

N want to merge records were submitted, there are two methods:

  1. From the beginning to the last few HEAD version nversion
git rebase -i HEAD~n
  1. Specify a range of merger startpointand endpoint, Note: The interval after a specified interval before opening and closing, meaning that startpoint not involved in merger
git rebase -i  [startpoint]  [endpoint]
  • -i mean --interactive, that interactive pop-up interface allows the user to edit the completion of the merger operation
  • startpoint and endpoint specifies a range of editing
  • If you do not specify the endpoint , the endpoint of the interval endpoint defaults to the current branch HEAD pointed to submit

operating

  1. Execution git logView commit history, then we will submit three merged into one submission

file

  1. Perform git rebase -i HEAD~3, pop-up window operation

file

Instructions:

  • pick: the retention commit (abbreviation: p)
  • reword: retention of the commit, but I need to modify the comment of the commit (abbreviation: r)
  • edit: to retain the commit, but I want to stop and modify the submission (not just modify comments) (abbreviation: e)
  • squash: a commit before the commit and combining (abbreviation: s)
  • fixup: the commit and a commit before the merger, but I do not keep the information submitted comments (abbreviation: f)
  • exec: execute shell commands (abbreviation: x)
  • drop: I want to drop the commit (abbreviation: d)

According to our demand, we will commit content editor as follows:

pick 85697ee This is first commit.
squash ee461c1 This is second commit.
squash 326e415 This is third commit.

The above means that the second and third submissions are merged into the first submission.

  1. Then save and exit, Git compresses commit history. If there is a conflict, need to change, modify time to pay attention, keep the most recent history, or we will discard the changes

After knocking modifications to remember the following command:

git add .  

git rebase --continue  

If you want to give up the compression, then execute the following command:

git rebase --abort
  1. If there is no conflict, or conflict has been resolved, the following editing window appears

file

We will merge into a three submissions submit information

Commit feature branch!

#This is first commit.
#This is second commit.
#This is third commit.
  1. You finish editing save commit to complete the merger, and we execute it git log

file

Then submitted to a public warehouse, there are no records submitted feeling a lot of refreshing, come try it!

Welcome to my personal blog

No public concern: JAVA half past nine classrooms , there are a number of outstanding programs ape, join us to explore technological progress together! Reply to "profile" the industry 2T get the latest information!

Guess you like

Origin www.cnblogs.com/noodlesmars/p/11864619.html