[英]git move/migrate commits from one branch to another
我想創建一個新分支並將幾個提交從MASTER移動到BRANCH。 我已經從MASTER commit A創建了BRANCH。
我可以使用cherry-pick ,但是看起來rebase會是更好的選擇。
我嘗試了這樣的命令(來自BRANCH):
git rebase --onto BRANCH A Z
但是輸出不符合預期:
Note: checking out 'b98885d'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
請指出我錯了-謝謝。
從Z的母版復制到BRANCH:
git branch BRANCH
當您仍然處於主狀態時,請重置回A:
git reset [--hard] A
BRANCH現在是master所在的位置,master現在在A上。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.