http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html
摘出幾個git指令
# 删除遠端分支
$ git push origin --delete [branch-name]
# 選擇一個commit,合并進目前分支
$ git cherry-pick [commit]
# 建立追蹤關系,在現有分支與指定的遠端分支之間
$ git branch --set-upstream [branch] [remote-branch]
# 使用一次新的commit,替代上一次送出
# 如果代碼沒有任何新變化,則用來改寫上一次commit的送出資訊
$ git commit --amend -m [message]
# 重做上一次commit,并包括指定檔案的新變化
$ git commit --amend [file1] [file2] ...
# 删除工作區檔案,并且将這次删除放入暫存區
$ git rm [file1] [file2] ...
# 停止追蹤指定檔案,但該檔案會保留在工作區
$ git rm --cached [file]
# 改名檔案,并且将這個改名放入暫存區
$ git mv [file-original] [file-renamed]
Git的設定檔案為.gitconfig,它可以在使用者主目錄下(全局配置),也可以在項目目錄下(項目配置)。
# 顯示目前的Git配置
$ git config --list
# 編輯Git配置檔案
$ git config -e [--global]
# 設定送出代碼時的使用者資訊
$ git config [--global] user.name "[name]"
$ git config [--global] user.email "[email address]"
# 顯示某個檔案的版本曆史,包括檔案改名
$ git log --follow [file]
$ git whatchanged [file]
# 顯示指定檔案相關的每一次diff
$ git log -p [file]
# 顯示暫存區和工作區的差異
$ git diff
# 顯示暫存區和上一個commit的差異
$ git diff --cached [file]
# 顯示工作區與目前分支最新commit之間的差異
$ git diff HEAD
# 顯示兩次送出之間的差異
$ git diff [first-branch]...[second-branch]
# 顯示某次送出發生變化的檔案
$ git show --name-only [commit]
# 顯示某次送出時,某個檔案的内容
$ git show [commit]:[filename]
# 恢複某個commit的指定檔案到工作區
$ git checkout [commit] [file]
# 生成一個可供釋出的壓縮包
$ git archive