撤销
# 恢复暂存区的指定文件到工做区
$ 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 // 建立新分支