撤銷
# 恢復暫存區的指定文件到工做區
$ git checkout [file]
# 恢復某個commit的指定文件到暫存區和工做區
$ git checkout [commit] [file]
# 恢復暫存區的全部文件到工做區
$ git checkout .
# 重置暫存區的指定文件,與上一次commit保持一致,但工做區不變
$ git reset [file]
# 重置暫存區與工做區,與上一次commit保持一致
$ git reset --hard
# 重置當前分支的指針爲指定commit,同時重置暫存區,但工做區不變
$ git reset [commit]
# 重置當前分支的HEAD爲指定commit,同時重置暫存區和工做區,與指定commit一致
$ git reset --hard [commit]
# 重置當前HEAD爲指定commit,但保持暫存區和工做區不變
$ git reset --keep [commit]
# 新建一個commit,用來撤銷指定commit
# 後者的全部變化都將被前者抵消,而且應用到當前分支
$ git revert [commit]
# 暫時將未提交的變化移除,稍後再移入
$ git stash
$ git stash pop12345678910111213141516171819202122232425262728293031
repo經常使用命令
repo init -u URL -b ........ // 建立.repo
repo upload // 將代碼提交到gerrit.
repo abandon master // 放棄master分支
repo forall -c "git reset --hard HEAD" // 全部代碼執行git命令,回退到HEAD
// repo sync至關於git clone會把repository中的全部內容拷貝到本地,非首次運行repo sync至關於更新和合並.
// repo sync會更新.repo下面的文件,若是在merge的過程當中出現衝突,這須要手動運行git rebase --continue.
repo sync -c -j 4
repo start master --all // 建立新分支