Git

Create Local Working Git Repository

Create .gitignore file

Add files and directoires that you DO NOT want put into the .gitignore file. A Rails app might add add the following to the file:

log/*.log
tmp/**/*
.DS_Store
doc/api
doc/app

Add .gitignore to Empty Directoires


$ touch log/.gitignore
$ touch tmp/.gitignore

Initialize Local Git Repository


$ git init
$ git add .
$ git commit -m "Added initial Rails app"

Create “Master” Remote Git Repository


$ ssh server.com
Welcome to server.com!
$ mkdir /var/git/app.git
$ cd /var/git/app.git
$ git --bare init
Initialized empty Git repository in /var/git/app.git
$ exit

Add Remote Repository to Local Repository


$ cd ~/Sites/app
$ git remote add origin username@server.com:git/app.git

Push to Remote


$ git push origin master

Pull from Remote


$ git pull origin master

Clone Remote Repository


$ git clone anotherusername@server.com:git/app.git

Links