我应该如何组织我的 Git 存储库和分支来创建网站的多个版本?
我是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我推荐阅读的一篇文章是成功的 Git 分支模型。它解决了您所描述的情况以及更多情况。
An article I recommend reading is A Successful Git Branching Model. It addresses the situations you describe plus some more.
请记住分布式。与 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 wouldgit pull
others work from origin repo (into some local branch) andgit push
their own work to appropriate branches of origin repo.正如 @Greg 所建议的,遵循 nvie 的成功 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: