工作中常用的Git/Repo 命令

在之前的项目中用的是Git,常用的命令如下:

1) Git clone

2)git fetch origin

3)git  reset --hard origin/XYZ

4) git status  ./

5) git  add ./

6) git  commit    git commit --amend

7) git push origin master:refs/for/master

8) git branch -a 

9) git checkout -b  XYZ  origin/XYA   //创建新分支XYZ,并切换到新分支XYZ上

10) git checkout  XYZ  //切换分支到XYZ上

11) git checkout -D XYZ    //删除分支XYZ

12) git blame  abc.cpp    //这个命令挺好,可以看到谁改的代码

 

 

现在项目中用repo了, 有点不适应,目前常用的命令如下:

1)  repo sync -c    

2)  repo rebase

3)  repo upload . --cbr   //只想上传当前检出的git分支,可以使用标志--current-branch (or --cbr 简写)

4)repo forall -c 'git reset --hard HEAD; git clean -dfx'; repo sync -cdj16;   //彻底同步服务器上的代码,对所有子项目进行了操作

     比较慢,但好用

 

欢迎补充,谢谢

 

其他的都是进入到对应的子项目中用git来操作

 

经常 repo sync -c    后出现 is published (but not merged) and is now N commits behind   错误

从网上搜索到 用 repo rebase就解决了。

 

 

你可能感兴趣的:(Repo/Git)