Git rebase is translated as a variable base in the book "Git authoritative guide". Let's look a bit awkward. It's time to change the base to cook, in "Pro git", it is translated into a combination, So git rebase will all use the translation method in "Pro git" in the future.
There are two ways to integrate the changes in one branch into another branch in git: Merge and rebase. Now, the following usage scenario is used to generate a branch Dev at the 3rd commit of the master branch, the Dev Branch has been submitted twice, and the master Branch has been submitted twice for some reason. Now we need to merge the dev Branch and the master branch, there are two ways to implement this. One is merge and the other is rebase.
The commit in the dev branch does not change when merge is used, which is important for others to use the secondary branch. However, this operation produces three commits, including one merge commit, therefore, merge is generally not used when the feature branches are merged to the master. The rebase operation looks like a sequential submission for convenient management. The specific rebase operation process is as follows:
- Make sure that the work zone is on the dev branch: git checkout Dev
- Execute the derivative operation: git rebase master
- If a conflict exists, resolve the conflict first and then execute: git rebase -- continue
- If you want to discard this operation, you can execute: git rebase -- abort
- If you want to directly replace this branch with the master branch, you can execute: git rebase -- skip
You can add the-I parameter to the rebase for interactive rebase,
Interactive rebase provides an easy-to-use way for you to split, merge, or reorder your submissions before sharing them with others. You can also use interactive rebase to clean up the submitted applications pulled from other developers. If you want to modify some of the commits during the rebase process, you can add the '-I' or '-- Interactive' parameter to the 'git rebase' command to call the interaction mode.
Git commit-I commit no.
When you use-I for interactive rebase, there will be some interactive commands.
# Commands:
# P, pick = use commit
# R, reword = use commit, but edit the commit message
# E, edit = use commit, but stop for amending
# S, squash = use commit, but meld into previous commit
# F, fixup = like "squash", but discard this commit's log message
#
# If you remove a line here that commit will be lost.
# However, if you remove everything, the rebase will be aborted. for example, you can use the pick Command to change the submission order without conflict. Using the squash command, git combines the submission with the previous commit into a new commit, which calls the editor again, you can merge the submission information of the two commits in it. If you specify to perform the 'edit' operation, git will do the same job, But before performing operations on the next commit, it will return to the command line for you to correct the submission or modify the submitted content. Another function of interactive rebase is to discard the submission, if you delete a row instead of specifying any of 'pick ', 'squash', and 'edit', git will remove the commit from the history. References:
- Http://book.douban.com/subject/3420144/
- Http://book.douban.com/subject/6526452/
- Http://blog.chinaunix.net/uid-27714502-id-3436706.html
- Http://blog.csdn.net/lihaoweiv/article/details/7740031
Use git rebase