简体   繁体   中英

Using a git repository for multiple projects

I have started using using git recently and use bitbucket also to host my code. I am comfortable with the basics such as making a branch, merging it and pushes, pulls etc but have a situation now which i'm not sure about.

I have basically developed a cms which I wish to use in multiple projects. I have a repository for this which I call 'cms_template'.

Whenever I wish to create a new project I just clone this into a new repository.

Basically my question is this: I have website A and website B. Both are clones of the cms_template repo but obviously will have changes in their own right as they are different websites. I don't want to push changes to these back to the cms_template repo but when I update the cms_template repo, I want these updates to be 'pullable' into each website. How do I best go about merging any updates I make to the original cms_template into these projects?

I also want to be able to push both website A and B to their own remote repositories also but am confused about the best way of doing this and not conflicting with the cms_template repo.

Hope my question makes sense - am happy to clarify if necessary.

Thanks in anticipation of your advice.

You should really look into using Composer for dependency management. That way you simply require a certain version of your CMS, and can update it independently from other projects.

You also avoid the hassle of git submodules, which are reported to have their issues (I cannot comment on that as I haven't got used them myself, but I am scared a bit and will probably avoid them if possible).

Using composer is as easy as downloading the phar file and adding a composer.json file into all your repositories to declare the dependencies and metadata. You also get an autoloader for free, and the ability to include any other library that offers Composer metadata or is registered at http://packagist.org (which is a lot.

See http://getcomposer.org/ for more info.

This sounds like the perfect setup for git submodules (see more info at http://git-scm.com/book/en/Git-Tools-Submodules )

Edit: Keep individual changes on cms branches from master and pull those in using submodules into your projects. Update your master cms branch whenever and rebase the website a/b ones afterwards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM