我应该如何组织我的 Git 存储库和分支来创建网站的多个版本?

发布于 2024-10-16 02:31:33 字数 700 浏览 9 评论 0原文

我是 SVN 用户,希望迁移到 Git。我整天都在阅读文档和教程,但仍然有一些未解答的问题。我不知道这个工作流程是否有意义,但这是我的情况,以及我希望从我的工作流程中得到什么:

  • 多个开发人员,全部在其工作站上进行本地开发
  • 网站的 3 个版本:开发、暂存、生产

这是我的梦想:

开发人员在他自己的分支上本地工作,说“developer1”,在他的本地计算机上进行测试,并提交他的更改。

另一个开发人员可以将这些更改拉到他自己的分支中。合并开发人员1 ->开发商2.

当作品准备好向公众展示时,我希望能够“推送”到开发、暂存或生产。

git push origin staging 

或者也许

git merge developer1 staging

我不确定。正如我所说,我对 Git 还很陌生。

以下是我的主要问题:

  • 我的网站(开发、暂存、生产)必须是存储库吗?它们是否必须“裸露”才能成为新更改的接收者?

  • 我想要一个存储库还是多个存储库(包含多个分支)?

  • 这是否有意义,还是我走错了路?

我读过很多教程,所以我真的希望有人可以帮助我解决我的具体情况。非常感谢!

I'm an SVN user hoping to move to Git. I've been reading documentation and tutorials all day, and I still have unanswered questions. I don't know if this workflow will make sense, but here's my situation, and what I would like to get out of my workflow:

  • Multiple developers, all developing locally on their work stations
  • 3 versions of the website: Dev, Staging, Production

Here's my dream:

A developer works locally on his own branch, say "developer1", tests on his local machine, and commits his changes.

Another developer can pull down those changes into his own branch. Merge developer1 -> developer2.

When the work is ready to be seen by the public, I'd like to be able to "push" to Dev, Staging, or Production.

git push origin staging 

or maybe

git merge developer1 staging

I'm not sure. Like I said, I'm still new to Git.

Here are my main questions:

  • Do my websites (Dev, Staging, Production) have to be repositories? And do they have to be "bare" in order to be the recipients of new changes?

  • Do I want one repository or many, with several branches?

  • Does this even make sense, or am I on the wrong path?

I've read a lot of tutorials, so I'm really hoping someone can just help me out with my specific situation. Thanks so much!

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

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

发布评论

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

评论(3

残花月 2024-10-23 02:31:33

我推荐阅读的一篇文章是成功的 Git 分支模型。它解决了您所描述的情况以及更多情况。

An article I recommend reading is A Successful Git Branching Model. It addresses the situations you describe plus some more.

风筝有风,海豚有海 2024-10-23 02:31:33

请记住分布式。与 subversion 不同,开发人员的签出是他们自己独立的存储库,而不仅仅是工作副本。在他们的正常工作流程中,他们会将更改提交到自己的存储库,创建和操作个人分支等。git Push可用于将提交从本地分支传输到您的“ main”,原始存储库(可能驻留在网络托管中)。因此,每个开发人员都将拥有本地个人存储库以及他希望的任何分支集;原始存储库将具有上述三个分支。开发人员有时会从原始存储库中git pull其他人的工作(到一些本地分支),并git推送他们自己的工作到适当的分支原始仓库。

Remember about the distributedness. Unlike in subversion, your developers' checkouts are their own independent repositories, not just working copies. In their normal workflow they would commit their changes to own repository, create and manipulate personal branches, etc. The git push can be used to transfer commits from local branches to your "main", origin repository (which will probably reside at webhosting). Therefore, each developer would have local personal repo with whatever set of branches he wishes; origin repository would have the three mentioned branches. Developers from time to time would git pull others work from origin repo (into some local branch) and git push their own work to appropriate branches of origin repo.

踏月而来 2024-10-23 02:31:33

正如 @Greg 所建议的,遵循 nvie 的成功 Git 分支模型是一个好主意。从那里,我建议阅读如何在网站上使用 git 并尝试在考虑分支模型的情况下实现它。

简而言之:

  • 遵循 git 分支模型 T
  • 设置您的系统,以允许 git 以第二篇文章建议的方式将您的发布分支推送到您的临时服务器
  • 设置 git 以将您的主分支推送到您的生产服务器,遵循相同的方法登台服务器设置

As @Greg suggested, following the Successful Git Branching Model by nvie is a great idea. From there, I would suggest reading about how to use git for websites and try to implement that with the branching model in mind.

In short:

  • Follow the git branching model to a T
  • Set up your system to allow git to push your release branches to your staging server in the manner suggested by the second article
  • Set git up to push your master branch to your production server following the same staging server setup
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文