Cheatsheet
Create
Clone an existing repository
$ git clone ssh://userdomain.com/repo.git
Create a new local repository
$ git init
Local Changes
View changed files in working directory
$ git status
Add all current changes to next commit
$ git add .
Add some changes to next commit
$ git add -p <file>
Commit previously staged changes with message
$ git commit -m 'message'
Commit history
Show all commits, starting with newest
$ git log
Who changed what and when in a file
$ git blame <file>
Branches and tags
List all existing branches
$ git branch -av
Switch HEAD branch
$ git checkout <branch>
Update and publish
List all currently configured remotes
$ git remote -v
Download changes and merge into HEAD
$ git pull <remote> <branch>
Publish local changes on a remote
$ git push <remote> <branch>
Merge and rebase
Merge branch into your current HEAD
$ git remote -v
Rebase your current HEAD onto branch (not for published commits)
$ git rebase <branch>
Undo
Discard all local changes in working directory
$ git reset --hard HEAD
Discard local changes in a specific file
$ git checkout HEAD <file>
Revert a commit
$ git revert <commit>
Setting up profile
Using username
$ git config --global user.name \'YOUR_USERNAME\'
Using email
$ git config --global user.email YOUR_EMAIL_HERE
Checking you config settings
$ git config --list
Last updated