我有3个分支:
现在我确实为master添加了一些更改。
任务是:将这些更改应用于test1和test2,但将这些分支保存为与master分开。
看起来很简单,但我无法解决这个问题。
现在,我尝试将test1与master合并:
git checkout test1
git merge master # already up-to-date
git pull origin master # up-to-date
git push origin test1 # Everything up-to-date
结果中没有来自master的更改。
尝试使用rebase:
git checkout test1
git rebase master
git status
On branch test1
Your branch and 'origin/test1' have diverged,
and have 1 and 7 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
git pull
由递归'进行合并。战略。 你的分支领先于原产地/测试1'由2个提交。
这两个提交是什么?我在master中有很多提交。
此外,当前分支中的主人仍然没有变化。
所以我只能用
恢复这些那么,我如何才能正确应用master的最新提交?
git reset --hard origin/test1
答案 0 :(得分:0)
为了让其他分支机构对其进行更改,请将其分开。 (好像它们是在不同的分支上独立开发的)我认为你应该尝试 git cherry-pick 。 https://git-scm.com/docs/git-cherry-pick