重新安排大师和发展分支机构
我有一个稳定且在线的Web应用程序。几周前,我决定开始工作新功能并创建了一个开发分支。从那以后,我已经完成了这一开发,并希望实现此功能。
我已经阅读了git rebase
,尽管我理解重新分支机构的概念,但从最佳实践意义上讲,我不确定如何应用它。我创建了第二个“虚拟”本地存储库来尝试一些事情。我的想法是,一旦开发完整并且稳定,这应该是您的新“稳定”(主)分支。因此,我尝试了:
git rebase开发主
:这最终奏效了,但我期望的是很烦人,因为它有几次冲突可以解决。但是,这意味着Master
分支具有所有新的开发功能。git rebase Master开发
:这要快得多,因为没有解决冲突要解决,但是,所有开发功能保留在development
分支上,这并没有反映在我的我的“稳定“主
分支。
在这两种情况下,一旦重新完成,我都通知我的本地分支从远程分支和git pull
将远程分支合并到我的本地分支(也许还有另一个问题)。
由于我是VC的新手,所以我不确定哪种是最佳实践方法?有人可以提供一些建议吗?我想拥有一个主要稳定分支(master
),并具有我的新功能。大多数人是否将开发重现到Master
和丢弃(从某种意义上说,它已存档)“旧” master
分支?还是我应该始终将主
重现到开发
以保持“稳定”分支的进展并在将来创建新的开发分支机构吗?
另一个问题是重新观察后的分支机构。这会在git拉拉
上产生问题,因为有太多的分解提交(请参见下图)。
你的想法是什么?最好的方法是什么?
I have a web application that is stable and online. A few weeks ago I decided to begin working a new feature and created a development branch. I have since completed this development and would like to make this feature live.
I have read up on git rebase
and while I understand the concept of rebasing a branch I am not sure how this should be applied, in the sense of best practices. I created a second "dummy" local repo to try a few things. My idea is that once a development is complete and stable this should be your new "stable" (master) branch. So I tried:
git rebase development master
: This worked eventually but was annoying as I expected since it had several conflicts to resolve. However, this meant themaster
branch has all the new development features.git rebase master development
: This was much quicker as there were no conflicts to resolve, however, all the development features remain on thedevelopment
branch and this is not reflected on my "stable"master
branch.
In both cases, once the rebase was complete I had notifications that my local branch had diverged from the remote branch and to git pull
to merge the remote branch into my local branch (perhaps another issue).
Since I am new to VCS I am not really sure which is the best practice approach? Can someone offer some advice? I would like to have a main stable branch (master
) with my new features. Do most people rebase development
onto master
and discard (in the sense, it is archived) the "old" master
branch? Or should I always rebase master
onto development
to keep a progression of the "stable" branch and create new dev branches in the future should the need arise?
The other issue is the diverging branches after a rebase. This creates problems on git pull
since there are so many diverged commits (see image below).
What are your thoughts? What is the best way to proceed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是:您需要合并(重新命名后)
开发
Master
forMaster
以反映开发
。重新构想的目标(第一步)是确保重新的
开发
分支仍然可以在最新的master
之上工作,请解决任何可能的可能冲突在当地。然后从
dev
合并到Master
是一个微不足道的,因为所有dev
提交已经在Master
的顶部。 。请注意,任何重新构想都需要
git推动-force
才能发布重新分支的新历史记录。如果您是唯一在该分支上工作的人,那没什么大不了的。Yes: you need to merge (after the rebase)
development
tomaster
formaster
to reflectdevelopment
.The goal of the rebase (as a first step) is to make sure the rebased
development
branch does still work on top of the up-to-datemaster
, resolving any possible conflict locally.Then the merge from
dev
tomaster
is a trivial one, since alldev
commits are already on top ofmaster
.Note that any rebase would require a
git push --force
to publish the new history of the rebased branch. If you are the only one working on said branch, it is not a big deal.