Use Git With Ruby on Rails Project

Install Git on Linux/Ubuntu

Well, in the previous article I’ve shown you ”Install Git on Linux/Ubuntu”, and in this article I want to show you “Create Ruby on Rails project and using Git”. Let’s run through this with me.

Create Ruby on Rails Project
Type command below to create a Rails project:

1
rails new todo -d mysql

Initialize Git
Type command below to initialize git:

1
2
cd todo
git init

Ignore File/Dir
Git uses file .gitignore to determine which files and directories to ignore, before you make a commit.

.gitignore file should be committed into your repository, in order to share the ignore rules with any other users that clone the repository.

Type command below to create a .gitignore file:

1
vim .gitignore

Then type file/dir or content that you want git to ignore:

.gitignore
1
2
3
4
5
6
log/*.log
tmp/**/*
config/database.yml
db/*.mysql
/public/assets/**
/vendor/bundle

Type command below to add Rails project into git:

1
git add .

Type command below to commit into git:

1
git commit -m "initialize income"

And type command below to push to the repository branch master:

1
git push origin master