如何在git中管理基于同一个模板的多个项目?
我最近使用 Rails 编写了一个非常简单且通用的博客软件,目前我已将其托管在 github 上。
我对使用 git 比较陌生,但我想使用这个项目作为模板来设计另一个我需要类似功能的项目(能够发布内容、留下评论等)。我还希望能够将新项目中的更改推回到旧项目中,如果我发现错误或想出一个我想要推回的新的通用功能。
在 git 中处理此设置的正确方法是什么?我应该分叉我的原始版本还是克隆它并推送到新的存储库,然后将原始版本添加为第二个远程版本,或者完全是其他东西?
I recently wrote a very simplistic and generic piece of blogging software using Rails that I currently have hosted on github.
I'm relatively new to using git, but I would like to use this project as a template for designing another project where I need similar functionality (ability to post something, leave comments on it, etc). I also want the ability to push changes from my new project back into the old one, should I find a bug or come up with a new common piece of functionality that I want to push back.
What would be the correct way to handle this setup in git? Should I fork my original or clone it and push to a new repository then add the original as a second remote, or something else entirely?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下,克隆就是分叉,所以没有区别。在这两种情况下,您都会获得历史记录,您需要的一切(或者更确切地说,您指定/默认的内容)。
是的,您提到的方法就是可行的方法。
您可以稍后将各个变更集推送到原始存储库,以在那里应用更改。
Cloning is forking in that case, so there’s no difference. In both cases you get the history, all you need (or rather, what you specify/defaults).
The approach you mentioned would be the way to go, yes.
You can push individual changesets to your original repo later on to apply the changes there as well.
我以前没有这样做过,但我曾经遇到过为版本控制存储库创建模板的情况。这就是我会做你想做的事。
最后一个拉动很重要,因为当模板发生变化时,人们不会喜欢他们的项目发生变化。 升级应该是自愿的并由项目团队规划。
我不会为此使用多个遥控器。
I haven't done this before, but I've been in the situation of creating templates for version control repositories. This is how I would do what you want.
The last pull is important because people won't appreciate having their projects change when their templates change. The upgrade should be voluntary and planned by the project's team.
I would not use multiple remotes for this.