25.使用变基合并分支

将分支恢复到合并之前

git checkout lgnew

git hist
*   1ef2ec3 2023-05-05 | Merge branch 'master' into lgnew (HEAD -> lgnew) [aku]
|\
| * 1c78eab 2023-05-05 | Added teset3.txt (master) [aku]
* | 3d99c8f 2023-05-05 | Added teset2.txt [aku]
|/
* 31e5621 2023-05-05 | Added teset2.txt [aku]
* 5dc8b1e 2023-05-05 | Added .gitignore [aku]
* b77158a 2023-05-05 | Moved test.txt to lab [aku]
* 929f644 2023-05-05 | Added 123456 to the test.txt [aku]
* d7f681f 2023-05-05 | Added abc to the test.txt (tag: v1) [aku]
* 01b8702 2023-05-05 | Add first file (tag: v1-beta) [aku]

# 重置到合并前的最后一次提交
$ git reset --hard 3d99c8f
HEAD is now at a3f191c Added test3.txt

变基

git rebase master
Successfully rebased and updated refs/heads/master.

git hist
* 2456c71 2023-05-05 | Added teset2.txt (HEAD -> lgnew) [aku]
* 31e5621 2023-05-05 | Added teset2.txt [aku]
* 5dc8b1e 2023-05-05 | Added .gitignore [aku]
* b77158a 2023-05-05 | Moved test.txt to lab [aku]
* 929f644 2023-05-05 | Added 123456 to the test.txt [aku]
* d7f681f 2023-05-05 | Added abc to the test.txt (tag: v1) [aku]
* 01b8702 2023-05-05 | Add first file (tag: v1-beta) [aku]

什么时候用变基

不用最好

Last updated