开发者

Creating a new project from a project skeleton using git

In order to get a new django project up and running faster, I'd like to maintain a separate "project skeleton" on which I base all my new projects. It would be great if, as I improved the skeleton, I could bring those improvements into my active projects. How can I accomplish this with git?

So, maybe in my remote git repository machine I woul开发者_Go百科d have 1 repo for each project and one for the skeleton?

  • proj-A-repo
  • proj-B-repo
  • skeleton-repo

If I want to create a new proj-C locally based on the skeleton, then push my local changes up to the remote server in a new repo called proj-C-repo, how might I do this?

I've read through quite a bit of git documentation, but I'm confused about how to go about this. Do I need to clone the skeleton, or create an empty repo and then track a remote branch, or something else?


This is exactly what git (or any DVCS) is good at. Give the skeleton its own repo; to create a new project you'd typically clone the skeleton onto your workstation, work away, then push to a different location (e.g. myserver:repo-C). If you later improve the skeleton and push changes to it, you can work them into an existing project with git pull myserver:skeleton and then merging.


You could do the following:

Create a Git repo that is your skeleton and add the stuff that's in A and B repo to your .gitignore. Then init new git repositories in A and B location and push to there.

That way you end up with:

skeleton
 +---> .git
 +---> project A
     +-----> .git
 +---> project B
     +-----> .git

I just tried this and it worked having a git repo inside a git repo, as long as you add the subrepo to the .gitignore..


You can find a good example of project skeleton with this sbt console template

If you clone it and launch sbt, you will get a fully functional Scala project:

  • which can be compiled, executed, tested and even eclipsified (to be imported as an eclipse project)!.
  • which can be stored in a Git repo of its own, with .gitignore already configured.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜