如何在我的分支中獲取一組提交,并將它們變基到臨時分支,然后變基回主分支?
更多詳細資訊 - 我的分支my-branch取決于feature1同事應該盡快推送的另一個代碼更改。我不想等他,所以我創建temp-feature1了包含所需更改的內容。我的計劃是 rebase my-branchabove temp-feature1,然后再次 rebasemain一次main包含所需的提交。
這就是我所做的:
在開發程序中
git checkout main
git checkout -b temp-feature1
# commit temp changes that I want to depend on (feature1)
git checkout my-branch
現在我可以在不等待我的大學提交的情況下進行開發。
一旦feature1合并到main我認為我可以簡單地做 -
git checkout main
git pull
git checkout my-branch
git rebase main
并從日志中洗掉我的temp-feature1提交,因為它已經在main.
但是,rebase 到 main 回傳了
Current branch my-branch is up to date.
并且temp-feature1提交仍然存在。
有沒有辦法獲得這個作業流程?
uj5u.com熱心網友回復:
您想要的作業流程是完全正常和正確的!問題僅僅是你給出了錯誤的rebase命令。你應該說
git rebase --onto main temp-feature1 my-branch
這只會撕掉你的my-branch分支提交temp-feature1并將它們推到main.
前:
A -- B -- C (main) -- H -- I (temp-feature) -- X -- Y (my-branch)
后:
A -- B -- C (main) -- X -- Y (my-branch)
(PS你需要停止混淆master,main我假設你的意思是main你所說的任何地方master。如果你有兩個main,master你可能會遇到大麻煩。)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/441106.html
標籤:混帐
上一篇:僅保留GitHub上的最新檔案
