I’m developing a website with two other team members using the FuelPHP framework. I would like to use git to maintain the project, but I’m having some trouble wrapping my head around the configuration. When I use oil to install FuelPHP, it installs the main framework as well as several submodules from github. The .git/config file in the document root looks like this:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git://github.com/fuel/fuel.git
[branch "1.4/master"]
remote = origin
merge = refs/heads/1.4/master
[submodule "docs"]
url = git://github.com/fuel/docs.git
[submodule "fuel/core"]
url = git://github.com/fuel/core.git
[submodule "fuel/packages/auth"]
url = git://github.com/fuel/auth.git
[submodule "fuel/packages/email"]
url = git://github.com/fuel/email.git
[submodule "fuel/packages/oil"]
url = git://github.com/fuel/oil.git
[submodule "fuel/packages/orm"]
url = git://github.com/fuel/orm.git
[submodule "fuel/packages/parser"]
url = git://github.com/fuel/parser.git
I have a bare repository setup on a remote server where I would like to maintain this project. I’d like to have the ability to pull updates from github for FuelPHP and it’s submodules, while also being able to push any changes to the bare repository so my team members and production server can pull from it. So far I’m running into a brick wall.
Here’s what I’ve done so far:
On the server:
$ mkdir websitename.git
$ cd websitename.git
$ git init --bare
On my local machine:
$ curl get.fuelphp.com/oil | sh
$ oil create websitename
$ cd websitename/
$ git remote add reponame ssh://git@example.com:2222/httpd/www/websitename.git
$ git push reponame 1.4/master
I get this response:
Counting objects: 14422, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4375/4375), done.
Writing objects: 100% (14422/14422), 2.20 MiB | 3.82 MiB/s, done.
Total 14422 (delta 9816), reused 14410 (delta 9810)
To ssh://haroldbr@haroldinc.com:2222/home/haroldbr/public_html/crude.git
* [new branch] 1.4/master -> 1.4/master
Then, on the server again:
$ git clone -l --no-hardlinks /httpd/www/websitename.git /httpd/www/websitename
which gives me this error:
Cloning into 'websitename'...
done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
Clearly I have a configuration problem, but I have no idea what it is. I want to be able to update all of the files in my remote repository using git. I envision it working something like:
On my local machine:
$ git pull origin 1.4/master
$ git push reponame --all
On the server:
$ cd websitename/
$ git pull
In a perfect world, this would pull all updates for FuelPHP and it’s packages from github and push all of those updates, along with any changes to the files in app/ or public/ to the bare repository. Is what I’m trying to do even possible? Do I need to setup repositories in app/ and public/ and maintain them separately? And what is wrong with my configuration that I can’t clone from the bare repo?
There is a screencast on how to use git to maintain a FuelPHP website project here: http://blip.tv/fuelphp/creating-a-fuelphp-application-repository-5688973, but it doesn’t cover pushing to a bare repository.
Assuming that you already have a new bare repository setup at ssh://example.com/path/to/project.git, you can follow these steps to setup your project. From your local machine:
You can then go to your production server and clone from the remote repository recursively to get your entire project:
You’ll then be able to track changes to your project while maintaining the ability to:
which will keep you up to date with the latest FuelPHP packages.