Skip to content

Commit 661b834

Browse files
committed
git rebase --onto tutorial
1 parent 8a448e5 commit 661b834

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,31 @@ git rebase master
912912

913913
git rebase 就是將 master 的最新 commit 接回來,再補上自己分支的 commit。
914914

915-
以上就是 git rebase 的介紹。
915+
以上就是 git rebase 的介紹,
916+
917+
另一種作法, 剛剛是必須切換到 v1 分支底下, 才執行指令,
918+
919+
如果你現在在任何分支(像是 master 分支), 你可以使用以下指令
920+
921+
```cmd
922+
git rebase master v1
923+
```
924+
925+
就是後面指定 v1, 執行完後它會自動幫你切換到 v1 分支上,
926+
927+
結果都是一樣的.
928+
929+
另外, 還有一個指令是 `git rebase --onto`
930+
931+
```cmd
932+
git rebase --onto <new base-commit> <current base-commit>
933+
```
934+
935+
其實概念上都是一樣的, 就是你想要 rebase 到哪個 new base-commit 上,
936+
937+
後面放 current base-commit 而已.
938+
939+
可以搭配 git graph 觀看, 或是看 git 的文檔 `git rebase --help`
916940

917941
## git rebase interactive
918942

0 commit comments

Comments
 (0)