Skip to content
Daniel Kehoe edited this page May 30, 2011 · 24 revisions

Using Git with Rails

This is a guide for developers using the example apps from the Rails Apps repository. Others may find it helpful as well.

If you are creating an application template, this step uses the git recipe from the rails_apps_composer repository.

Background

If you’re creating an app for deployment into production, you’ll want to set up a source control repository at this point. If you are building a throw-away app for your own education, you may skip this step.

Setting Up Git

Check that git is installed on your computer:

$ git version

Rails has already created a .gitignore file for you. You may want to modify it:

.bundle
db/*.sqlite3
log/*.log
tmp/
.DS_Store

Initialize git and check in your first commit:

$ git init
$ git add .
$ git commit -am 'initial commit'

You can check your commit status at any time with:

$ git status

Save it to GitHub

Use a remote source control repository if you want an offsite copy of your work or you plan to share your work with others.

We’ll assume you have an account at GitHub. Check that your GitHub account is set up properly:

$ ssh git(at)github.com

Go to GitHub and create a new empty repository (http://github.com/repositories/new) into which you can push your local git repo.

Add GitHub as a remote repository for your project and push your local project to the remote repository:

$ git remote add origin git(at)github.com:YOUR_GITHUB_ACCOUNT/YOUR_PROJECT_NAME.git
$ git push origin master

At each stage of completion, you should check your code into your local repository:

$ git commit -am "some helpful comment"

and then push it to the remote repository:

$ git push origin master

Clone this wiki locally