简体   繁体   English

如何将远程主分支转换为本地开发分支?

[英]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 文档它暗示变基时(在实施例其表示衍合developmaster ):

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. 请注意,例如, GitHubAtlassian在其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.

相关问题 无法将更改从本地 master 分支推送到远程 master 分支 - Can not push changes from local master branch to remote master branch 如何将远程开发分支重置为master - How to reset develop branch on remote to master 如何将本地分支开发推送到远程分支develop_1 - How to PUSH local branch develop to remote branch develop_1 如何用Remote上的Develop Branch替换Master Branch文件? - How to replace Master Branch files with Develop Branch on remote? 如何通过丢弃所有更改来将所有更改从远程源主分支复制到本地的新分支 - How to copy all changes from the remote origin master branch to a new branch on local by discarding all changes of it 如何将尚未合并到master中的远程分支拉到本地分支中? - How to take a pull of a remote branch that has not been merged into master into a local branch? 如何将更改从一个远程分支转移到另一个远程分支 - How to take changes from one remote branch to other remote branch 从远程开发分支创建本地分支 - creating local branch from remote develop branch 如何更新我的本地 master 分支以包含对我的本地 feature 分支所做的更改,这些更改在 origin (remote) master 上是最新的? - How to update my local master branch to include changes made to my local feature branch that are up-to-date on origin (remote) master? 提交到主分支将子分支将进行更改 - Commit to master branch will sub branch will take the changes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM