git rebase two cross branch exchange base

1 Move base downstream

Move the base downstream, the root node is the intersection of the two branches

1. Initialize the data

* c54f8b7 (HEAD -> b) version3 b
| * f9fc6be (a) version4 a
| * 730cb6a version3 a
|/
* 604ad92 version2 //a和b的交点,既base
* 648ef5e version1

Insert picture description here

2.rebase change base
At this time HEAD is on branch b, we can now base is version2, we can change the base of branch b to any position of version1~4, assuming rebase to version3 a
git rebase 730cb6a

Equivalent graphics operations are used here
1)
Insert picture description here
Insert picture description here
Insert picture description here
2) Handle conflicts
Insert picture description here

3). Fill in the submission information
Insert picture description here
3. As a result
, the base of branch b has changed
Insert picture description here

2 Move base upstream

Move base upstream, base is the designated upstream commit point

Suppose that you want to move to version2 and
Insert picture description here
version2 is base. In this way, branch b will have two commits, verson3 a and version 3 b.
If you want to restore to the original state, you can Actionchange version3 a skipto
Insert picture description here

Guess you like

Origin blog.csdn.net/claroja/article/details/114993117