Git(Repo)常用命令收集

(注意: 只记录工作中实际使用的命令)  

  同步android源码    repo sync;(可加-c,只取当前分支; 可加-j4,线程数量)

  查看android源码下所有项目的git状态    repo forall -c "pwd;git status"

  同步代码前覆盖本体没有提交的代码     repo forall -c "git checkout . ";


  将提交推送到gerrit服务器评审:
  git push origin local_branch:refs/for/server_branch 或者repo upload . 。

  查看差异:
  git diff(工作目录-本地库);git diff HEAD(工作目录-缓冲区);git diff --cached(缓冲区-本地库)。

  查询历史信息:
  git log  --oneline(单行显示) -数字(指定条数) --graph--all(图形方式显示多条分支信息)  --stat(显示文件变动列表) -p(显示文件变动具体内容) 文件名(指定文件) 提交范围(例如git log fwj9e8..HEAD)。


原文地址:https://www.cnblogs.com/yuanchongjie/p/4448383.html