Git: Adding a Ruby on Rails Project to Git

Here’s how to add a recently created Ruby on Rails project to git:

1. Create your new project:

$ rails -d mysql project_name

2. Create some .gitignore empty files so you save the entire structure of your project (git doesn’t include empty folders):

$ touch db/.gitignore lib/.gitignore log/.gitignore tmp/.gitignore vendor/.gitignore

3. Create a new .gitignore file in the root directory of your project with the following content:

log/**/*
tmp/**/*
db/schema.rb

Note: If you are using sqlite add db/*.sqlite3 to .gitignore so you do not have the database into the repository (you can db:migrate it whenever you need it). Thanks for your reply Piku.

4. Initialize local repository:

$ git init

5. Add the project files and make que initial import:

$ git add .
$ git commit -a -m "* Initial import"

6. Finally if you have a gitosis server you can add it with the following commands:

$ git remote add origin git@YOUR_SERVER_NAME:project_name.git
$ git push origin master

That’s it, your project sources are now managed by git.

Happy hacking!

Advertisements
Git: Adding a Ruby on Rails Project to Git

3 thoughts on “Git: Adding a Ruby on Rails Project to Git

  1. If you are using sqlite add db/*.sqlite3 to .gitignore so you do not have the database into the repository (you can db:migrate it whenever you need it).

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s