Git, GitHub and Ruby on Rails

Learning those things, will be posting snippets now and then…

# Git

# First-time system setup
git config --global user.name USERNAME
git config --global user.email EMAILADDRESS
git config --global core.editor "vim"

# First-time repository setup
git init
# Initialized empty Git repository in /home/vincent/Documents/aproject/.git/

# About .gitignore
# Pattern stored in this file will be ignored by git

# Comparison to Subversion
svn add *               git add .
svn status              git status
svn commit -m "msg"     git commit -m "msg"
svn log                 git log
svn checkout            git checkout -f (--force)
svn mv a.php b.php      git mv a.php b.pp

# Commit all (still need to "git add ." first for new files)
git commit -a -m "msg"

# Branch

# Create a new branch and switch to the new branch
git checkout -b BRANCHNAME

# Switch to an existing branch "master"
git checkout master

# List existing branches
git branch

# Merge a branch's modification into another branch
# Switch to the target branch
git branch master
# Merge into master
git merge master

# Delete branch
git branch -d TEMPBRANCH

#-----------------------------------------------------------------------

# GitHub

# Set up GitHub account locally
git remote add origin git@github.com:digitalwingx/APPNAME.git

# Push local git repository to GitHuba
git push origin master

#-----------------------------------------------------------------------

# Deployment to Heroku

# Install heroku gem
gem install heroku

# Sync local ssh key to heroku
heroku keys:add

# Create new application at Heroku (require git)
heroku create

# Push from git to heroku
git push heroku master

# Rename Heroku application name and url
heroku rename NEWNAME