我在git存储库中有develop
个分支。
git log
显示的内容类似于:
commit 111
Commit Last
commit 222
Commit Last-1
commit 333
Commit Last-2
我想做的是:
1. Revert to #333
2. Create a branch Branch-111 which will contain #333 + #111
3. Create a branch Branch-222 which will contain #333 + #222
这些新分支仅应从#333和指定分支之一更改。
我试图创建2个补丁。但是我无法在#333上应用它们-我有多个patch does not apply
解决此任务的正确方法是什么?
答案 0 :(得分:2)
git branch branch222 develop~1 # this branch can be kept as is
git checkout -b branch111 develop~2
git cherry-pick develop # apply 111 change
git branch -f develop develop~2 # take back develop 2 revisions
那应该做
答案 1 :(得分:0)
您可以解决的一种方法是:
git checkout -b Branch-111 <hash of "commit 111">
git rebase -i HEAD~~~
# delete line for "commit 222"
git checkout -b Branch-222 <hash of "commit 222">