Thursday, June 5, 2014

GIT: cheat sheet

Install GIT

Install Brew - Mac package installer

$ ruby -e "$(curl -fsSL"

Check existing version of git

$ git --version
git version (Apple Git-48)

Install the latest and greatest git version

$ brew install git
 /usr/local/Cellar/git/1.9.0: 1322 files, 30M
$  git --version
git version (Apple Git-48)
uki@ bin $ /usr/local/Cellar/git/1.9.0/bin/git --version
git version 1.9.0

Edit the PATH so he new GIT tool is found first

edit ~/.profile
# GIT tool path
export GIT_TOOL=/usr/local/Cellar/git/1.9.0/
export PATH=${GIT_TOOL}/bin:${PATH}
$ git --version
git version 1.9.0


Checking Status - what has changed 

$ git status

Fetching remote changes

$ git fetch

Rebasing - placing your changes on top of remote changes 

$ git rebase

Branch Operations

Switch to an existing branch

$ git checkout develop

Create a new branch named thrift

$ git checkout -b thrift

Delete an existing branch

$ git branch -D thrift

Resetting - removing local changes

reset hard to previous commit

$ git reset --hard 9a5xxx317

reset hard to latest local

$ git reset --hard HEAD

see what is different

$ git diff HEAD FETCH_HEAD