其實你可以不用 cherry-pick
- Productivity
- 27 Apr, 2020
如果今天有三支 branch:master、staging、feature/b。本來你在開發中的 feature/b 是從 staging 長出來的分支,但是現在你必須將 feature/b 的內容轉移到 master 上,如圖,你會怎麼做呢?
從 master 重新長一個分支然後再把用 git cherry-pick 把 commit 一個一個搬過來?其實你可以聰明地使用 git rebase :
git rebase --onto master s0002 feature/b
或是
git rebase --onto master b0001~ feature/b
就可以只把想要的範圍內的 commit,rebase 到新的 base 上。