English 中文(简体)
Git environment for CodeIgniter project
原标题:

I m starting of with a new CI project based on the CI 2.0 Reactor repository. Because the CI2 code is still changing, I would like to keep that code fresh, the question is how (using Git).

For the non-CI folks, the basic structure of a CI2 project looks like this:

system/  
application/  
index.php
...

The system directory contains the framework, index.php does the bootstrapping and application contains my project. Ideally, I would like to keep both index.php and the system folder up-to-date using Git. Another thing I would like to adhere to is name of the application folder. (You can change the path of your application folder in index.php.) Keeping the name the same makes it possible to just drop in the folder, and off you go.

I ve tried to realize this by using git submodules (see below), but submodules don t let you specify a directory from the target repository.

git submodule add https://github.com/philsturgeon/codeigniter-reactor.git/code-igniter/system system

Any clue how I can achieve this?

最佳回答

Sadly you cannot reference a specific folder in a sub-module, only the root of the sub-module itself. That would mean you need to put your application in a sub-folder, which would be crap.

You can however just set up two remotes on your Git application.

git init
git remote add origin git://whatever
git remote add reactor git@github.com:philsturgeon/codeigniter-reactor.git

Then update with reactor changes

git pull reactor master
git push origin master

Remember that this clone is really intended to help people get their CodeIgniter Reactor changes int without needing to learn Mercurial, but you are welcome to use it as long as it exists.

问题回答

I stumbled in the same problem too.

I really want use git to bring the codeigniter core with the application without copy and paste the updates every time! There are a lot of advantages to use git submodules (and who use git already know that).

So I did it in this way:

mkdir yourapp
cd yourapp
git init
git sudmodule add git://github.com/EllisLab/CodeIgniter.git codeigniter
mkdir public
cp codeigniter/index.php public/
cp -rp codeigniter/application .

Now edit public/index.php and change:

$system_path =  system ;

to:

$system_path =  ../codeigniter/system ;

and:

$application_folder =  application ;

to:

$application_folder =  ../application ;

Now point your webserver to your "public" folder and it s done! Now you have a project with codeigniter as a submodule :)

For things like this, I update them manually and check for conflicts.

Not a real answer to your question, but in general it is not a good idea to trust changing third party projects: an update can break your application without warning. I would advise to update it manually every now and then and test your application after the update. This way sudden breaks of your application are less likely to happen.

I ve never run into a project or framework where you save the framework core in your github repo OR pull it in directly through another repo. You should be relying on composer for things like that.





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签