重新安排大师和发展分支机构

发布于 2025-01-22 13:01:31 字数 1260 浏览 3 评论 0原文

我有一个稳定且在线的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 the master 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 the development 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?

Diverging commits after rebasing development onto master

Diverging commits after rebasing master onto development

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

別甾虛僞 2025-01-29 13:01:31

git rebase大师开发:这要快得多,因为没有解决的冲突要解决,但是,所有开发功能保留在开发分支上,这并没有反映在我的“稳定”大师分支上。

是:您需要合并(重新命名后)开发 Master for Master以反映开发

重新构想的目标(第一步)是确保重新的开发分支仍然可以在最新的master之上工作,请解决任何可能的可能冲突在当地。

然后从dev合并到Master是一个微不足道的,因为所有dev提交已经在Master的顶部。 。

请注意,任何重新构想都需要git推动-force才能发布重新分支的新历史记录。如果您是唯一在该分支上工作的人,那没什么大不了的。

git rebase master development: This was much quicker as there were no conflicts to resolve, however, all the development features remain on the development branch and this is not reflected on my "stable" master branch.

Yes: you need to merge (after the rebase) development to master for master to reflect development.

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-date master, resolving any possible conflict locally.

Then the merge from dev to master is a trivial one, since all dev commits are already on top of master.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文