Need help?

I'm available for remote short term contracting or consultancy work. Please check out my LinkedIn profile for more details on my experience.

Please feel free to use the form below to contact me.




Using Symfony2 with git (version control system)

Do you really like Symfony2, but want to find out how to set it up to use git? That's pretty easy, and I can walk you through all the steps involved.

First, I'm going to assume that you already have a Symfony2 project setup and working. The only other thing you'll need is git installed. You can follow the steps on the following site, to get the most current git distribution set up.

http://git-scm.com/book/en/Getting-Started-Installing-Git

Okay, now we're all set, and git is installed. Lets navigate to your project directory (using command line) - that should be the one that has the following directory structure:


app/
bin/
LICENSE
README.md
src/
vendor/
web/

You might have or 1 or more files/directories than me, but as long as you have the basics, it should be good.

Lets begin by initializing the git repository - type the following into the command line:


git init

What that does is creates your repository and does all the hard stuff for you - real simple. The next step will be setting up the .gitignore file. This will be the file that git will check first, and make sure it doesn't add any of those 'ignored' files/directories to the repository.

Create .gitignore, and add the following into it:


/nbproject/
/web/bundles/
/app/cache/*
/app/logs/*
/vendor/
/app/config/parameters.ini

You can omit /nbproject/ if you're not using Netbeans as your IDE - it just keeps git from adding all the meta files to the repository. If you have any config files that are unique to each system, you can add those to the ignore list as well.

Okay, we're almost done - the next thing you need to do is run the following command, to add all the files.


git add .

The '.' just tells it to add all the files from the current directory you're in. I'm sure you knew that, but thought I'd explain anyways.

And the final set is the commit process.


git commit -m "Initial commit"

That's it - you're all done. The only catch is that it's only stored on your local machine now (or where ever you have your code base), but it'd be nice to have it backed up on a central repository as well.

I'd recommend signing up with codebase - they offer free (or paid) git hosting services, which will give you off-site storage. This way you can push your repository up to that, and keep it updated.


jon | August 05, 2012 | Comments (0)

Comments


Name (required)
Email (will not be published) (required)
Website

captcha