开发者

How to manage multiple projects based on the same template in 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?


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.

  1. Create a small family of templates by cloning. Make the set read-only from outside the family.
  2. To create a new project, clone from a template.
  3. When you find something that you want to add to or remove from a template, edit a working copy of the template, and push. Do this even if it means making the change twice: once in a project, and once on the template.
  4. Pull from projects to upgrade them to the latest version of their template.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜