[英]git merge into the middle of the main commits where feature branch started
如果您打算合並功能分支並一次性應用 main 的倒數第二個修訂版的更改(圖表顯示為所需結果的方式),則需要進行一些修改
git checkout main~2
git merge --no--ff featureBranch
git cherry-pick main~
git reset --soft @~ # set HEAD pointer in merge revision we just created
# changes from main~1 are in index
git commit --amend -m "merge and changes from main~1 in a single revision"
git cherry-pick main
# if you like the result
git branch -f main
git checkout main
就是這樣。
git rebase feature main
git replace --graft $(git rev-list feature..main|tail -1) \
$(git merge-base feature main@{1} feature
git filter-branch
rebase 得到你想要的內容,replace 設置了奇怪的祖先,filter-branch 將它烘焙進去。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.