Create Repository
From existing directory
cd project_dir
git init
git add
From other repository
git clone existing_dir new_dir
git clone git://github.com/user/repo.git
git clone https://github.com/user/repo.git
Changes
Changes in working directory
git status
Tracked file changes
git diff
Add changed files
git add file1 file2 file3 ...
Remove file
git rm file
See files ready for commit
git dif --cached
Commit changes
git commit
git commit -m "message"
git commit -am "message"
(auto add tracked files)
Change last commit
git commit --amend
Revert changes to file
git checkout -- file
Revert changes (new commit)
git revert HEAD
Return to last commited state
git reset --hard HEAD
History
Show all comits
git log
Show file commits
git log file
Show directory commits
git log dir/
Who changed file
git blame file
Merge/Rebase
Merge branch into current
git merge branch
Rebase into branch
git rebase branch
git rebase master branch
Remote Update / Publish
List remotes
git remote -v
Show information
git remote show remote
Add remote
git remote add path/url
Fetch changes
git fetch remote
Fetch + merge
git pull remote branch
Publish local to remote
git push remote branch
Delete remote branch
git push remote :branch
Branches
List branches
git branch
Switch to branch
git checkout branch
Create new branch
git branch new
Create branch from existing
git branch new existing
Delete branch
git branch -d branch