[英]How to take remote master branch changes into local develop branch?
I want to take update into my develop branch from master, what I tried to do is applying below commands: 我想从master那里将更新带入我的开发分支,我试图做的是应用以下命令:
git checkout master
git pull
git checkout develop
git rebase master
By executing the above commands I am getting below warning: 通过执行以上命令,我得到以下警告:
First, rewinding head to replay your work on top of it... 首先,快退一下,重播您的作品...
Also, I am not sure whether I should perform rebase
or merge
from master to develop. 另外,我不确定是否应该执行
rebase
还是从母带merge
到开发。 I referred a couple of articles online and in one it is suggested as 我在网上提到了几篇文章,其中一篇建议为
Rebases are how changes should pass from the top of hierarchy downwards and merges are how they flow back upwards.
重新确定基准是更改应如何从层次结构的顶部向下传递,而合并则是更改如何向上流动。 ( Link )
( 链接 )
And in Microsoft Docs it is suggesting to rebase when(In example its showing rebasing develop
onto master
): 并在Microsoft 文档它暗示变基时(在实施例其表示衍合
develop
到master
):
A suggested approach is to allow rebasing local changes that you have made but haven't shared with others, but to merge once you are sharing changes with others.
建议的方法是允许对您已进行但尚未与其他人共享的本地更改进行基础计算,但是一旦与其他人共享更改就可以合并。 This avoids trouble with rewriting history while still letting you easily catch up with changes as you develop your code locally.
这避免了重写历史记录的麻烦,同时仍使您可以在本地开发代码时轻松赶上更改。
I would like to know the best approach to take the latest changes from master
branch to develop branch. 我想知道从
master
分支到开发分支进行最新更改的最佳方法。
In my humble opinion, unless you're a confident git user, git rebase (-i)
, causes more issues than it solves. 以我的拙见,除非您是一个有信心的git用户,否则
git rebase (-i)
会导致更多问题,而不是解决的问题。
Please note that, for example, neither GitHub nor Atlassian in their git flow tutorials use rebasing. 请注意,例如, GitHub和Atlassian在其git flow教程中均未使用重定基。
Of course git flow is just one approach and Atlassian in their Feature Branch Workflow article writes: 当然,git flow只是一种方法,Atlassian在其Feature Branch Workflow文章中写道:
Once Bill is ready to accept the pull request, someone needs to merge the feature into the stable project (this can be done by either Bill or Mary):
一旦Bill准备好接受拉取请求,就需要有人将功能合并到稳定的项目中(这可以由Bill或Mary来完成):
git checkout master git pull git pull origin marys-feature git push
This process often results in a merge commit.
此过程通常会导致合并提交。 Some developers like this because it's like a symbolic joining of the feature with the rest of the code base.
一些开发人员喜欢这种方式,因为它就像该功能与其余代码库的符号连接。 But, if you're partial to a linear history, it's possible to rebase the feature onto the tip of master before executing the merge, resulting in a fast-forward merge.
但是,如果您偏向于线性历史记录,则可以在执行合并之前将特征重新设置到母版的顶端,从而实现快速合并。
I'm a merge commit proponent and I would encourage you to not use rebasing. 我是合并提交的支持者,我鼓励您不要使用重新定级。
First, rewinding head to replay your work on top of it...
首先,快退一下,重播您的作品...
That is not a warning. 那不是警告。 That's normal output for rebase.
这是重新设置基准的正常输出。 If there's a warning, git will tell you so (
WARNING:
like you'd see CONFLICT:
). 如果有警告,git会告诉您(
WARNING:
就像您看到的CONFLICT:
)。
Note: Fast forward rebases aren't acutally doing any work - no merging, no rewinding of HEADS. 注意:快进rebase并不会做任何工作-不会合并,也不会倒退HEADS。 So git doesn't output that line, even if you use
git rebase
因此,即使您使用
git rebase
,git也不输出该行
As for choosing between merge and rebase, it's convention in most scenarios. 至于在合并还是变基之间进行选择,在大多数情况下都是惯例。 Follow the convention your team wants you to use - if they primarily rebase changes onto master, then do that.
遵循您的团队希望您使用的约定-如果他们主要将更改基于基础,然后执行。
If there's no convention handed down, do as your gut tells you to. 如果没有约定,请按照您的直觉告诉您。 Merge preserves order of commits according to time, clearly shows the divergence and then convergence, as it happened in real life.
合并会根据时间保留提交的顺序,清楚地显示出发散和收敛,就像现实生活中发生的那样。 Rebase makes the history look seamless and clean (by editing history, hence why pulled-by-others branches shouldn't be rebased).
Rebase使历史记录看起来无缝且整洁(通过编辑历史记录,因此为什么不应该对其他牵引的分支进行重新定位)。
I try to use rebase. 我尝试使用rebase。 I like clean history - this person changed ABC, then I changed XYZ on top of it.
我喜欢干净的历史记录-这个人更改了ABC,然后又更改了XYZ。
I would avoid rebasing. 我会避免变基。 If you made some commits directly into master (not a great idea) and need to bring them to develop -
如果您直接将一些承诺提交给大师(不是一个好主意),并且需要带动他们发展-
git checkout develop
git merge master
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.