git rebase usage scenarios

1. After the backward pull of the current branch, finishing commit, commit history to make a straight line

pull Git
Git log // bifurcation occurs, finishing
git rebase // move the position of commit, commit to pull over the front of the discharge, a discharge is commit the rear, a straight line

2. The other branches merged into master, finishing first in a straight line, and then merge

1. open up the CheckBox -b feature feature branch git
2. submit commit the feature branch
3. combine multiple commit in a feature git reabse -i, simplify the submission history. This can reduce the number of conflict resolution in git rebase time.
4. In the feature git pull origin master --rebase (equivalent to git fetch origin master, git rebase origin / master)
                                                                    will master the latest commit to this branch of sync, you may want to resolve the conflict manually (merger process, the abnormal exit vi window,
                                                                    with git rebase --edit-todo recovery, you modify, git rebase --continue continuing,
                                                                   ignored, git rebase --skip, termination, -abort rebase with git)
5. cut back to master, git merge feature branch will feature content incorporated into the master
6. git master submit the Push

So, master's commit history will be a straight line.

3. A plurality of branches continuously copied to commit other branches

git rebase [startpoint] [endpoint] --onto [branchName] // add commit to a plurality of consecutive target branch branchName, [startpoint] [endpoint] is after a specified interval before the opening and closing

E.g:

git rebase 90bc0045b ^ 5de0da9f2 --onto master // 90bc0045b ^ back a commit, make a [90bc0045b, 5de0da9f2] closed interval

After rebase need

git reset --hard commitId // HEAD of the branch point id submitted

4. commit combined

git rebase -i [startpoint] [endpoint] // [endpoint] may be omitted, combined into a plurality commit, squash mode using

E.g:

git rebase -i HEAD ~ 3 // 3 forward the commit, up to now, the merger

5. commit Split

git rebase -i commit changed to pick the specified edit, edit split

6. commit sort

git rebase -i commit order to modify the list

7. Change the branching source

git checkout feature2

git rebase master

feature2 starting point can be changed from the master branch to another branch

 

reference:

https://baijiahao.baidu.com/s?id=1633418495146592435&wfr=spider&for=pc
https://www.liaoxuefeng.com/wiki/896043488029600/1216289527823648
https://blog.csdn.net/nrsc272420199/article/details/85555911
https://www.codercto.com/a/45325.html

Guess you like

Origin www.cnblogs.com/mengff/p/11608864.html