如何使用新内容更新我的功能/发布/修补程序/支持分支?

时间:2013-04-01 10:52:01

标签: git

例如,我正在处理功能分支,另一位开发人员现在正在推动他/他的最新修补程序,我必须在我的功能分支中使用(添加)他的修复程序。

我应该怎么做?

git checkout -b my-feature-branch
... dealing with my issue ...
... alarm! another developer just released his fix, I need it here in my feature branch ...
git stash
git checkout develop
git pull origin develop
git rebase my-feature-branch develop
git checkout my-feature-branch
git merge develop
git stash apply
... dealing with my issue ...
git commit
git checkout develop
git merge my-feature-develop
git push origin develop

这是正确的行为吗?

在这种情况下很难弄清楚我的分支在哪里开始以及在哪里完成。 第二点我正在为公共分支(开发)做rebase并且它不好,对吧?

使用新信息更新(刷新)工作分支的正确方法是什么?

2 个答案:

答案 0 :(得分:0)

找到修补程序的提交,然后cherry-pick它/它们。

答案 1 :(得分:0)

这似乎不对:git rebase my-feature-branch develop

应该是:

git rebase develop my-feature-branch`

您需要做的是在现在更新的my-feature-branch分支的基础上重新设定您在develop中已经完成的工作。
无需merge my-feature-branch git checkout -b my-feature-branch ... dealing with my issue ... ... alarm! another developer just released his fix, I need it here in my feature branch ... git stash git checkout develop git pull origin develop # remember that such a rebase will starts with a # git checkout my-feature-branch git rebase develop my-feature-branch git stash apply ... dealing with my issue ... git commit git checkout develop git merge my-feature-develop git push origin develop 开发。{/ 1}

然后完整序列看起来像

{{1}}