Setting up a new Rails app with Git
11 Sep 2009Ok so you want to be cool like all other rails developers out there and use Git for your projects. Here is a quick run down of how you might go about it.
Firstly create your rails app and using terminal go into the root of that project.
Then create a top, project-level .gitignore file. I use textmate so this can be done like so
$ mate .gitignore
Then add the following to the .gitignore file
.DS_Store
log/*.log
tmp/**/*
config/database.yml
db/*.sqlite3
You can also add more directories or files in here to ignore like css files if using sass for example, or your uploads directory.
Create some .gitignore files so the empty directories get tracked:
$ touch log/.gitignore
$ touch tmp/.gitignore
and finally commit that bad boy
$ git add .
$ git commit -m "First commit"
Running git add will tell git to track all the new files (Since first commit thats all of them). The commit will commit to your local Git repository and all that is left to do would be to add it to GitHub for example and your in business.