2021-07-15 Android repo 使用学习持续更新中

1、repo常用命令

xxx$ .repo/repo/repo  help
usage: repo COMMAND [ARGS]
The most commonly used repo commands are:
  abandon        Permanently abandon a development branch
  branch         View current topic branches
  branches       View current topic branches
  checkout       Checkout a branch for development
  cherry-pick    Cherry-pick a change.
  diff           Show changes between commit and working tree
  diffmanifests  Manifest diff utility
  download       Download and checkout a change
  grep           Print lines matching a pattern
  info           Get info on the manifest branch, current branch or unmerged branches
  init           Initialize repo in the current directory
  list           List projects and their associated directories
  overview       Display overview of unmerged project branches
  prune          Prune (delete) already merged topics
  rebase         Rebase local branches on upstream branch
  smartsync      Update working tree to the latest known good revision
  stage          Stage file(s) for commit
  start          Start a new branch for development
  status         Show the working tree status
  sync           Update working tree to the latest revision
  upload         Upload changes for code review
See 'repo help <command>' for more information on a specific command.
See 'repo help --all' for a complete list of recognized commands.

2、查看分支repo branches或者repo branch

3、切换分支 repo start BRANCH_NAME PROJECT_NAME

4、所有项目切换到某分支 repo start branch-name --all

5、查看代码状态 repo status . 或者 repo status PROJECT_NAME

6、查看本地repo管理的所有projects

7、各个目录下的仓库管理文件.git实际上是链接到.repo/projects/下面对应的仓库。

8、删掉vendor目录,vendor下是有三个项目,如何还原这三个项目呢?执行repo sync -l 项目名。或者repo sync -l 全部更新本地的项目。

9、repo 撤销本地修改的代码,使用 repo forall  [project...] -c “git checkout .”

     9.1简单介绍 repo forall -c

Usage: repo forall [<project>...] -c <command> [<arg>...]
repo forall -r str1 [str2] ... -c <command> [<arg>...]"

Options:
  -h, --help            show this help message and exit
  -r, --regex           Execute the command only on projects matching regex or
                        wildcard expression
  -i, --inverse-regex   Execute the command only on projects not matching
                        regex or wildcard expression
  -g GROUPS, --groups=GROUPS
                        Execute the command only on projects matching the
                        specified groups
  -c, --command         Command (and arguments) to execute
  -e, --abort-on-errors
                        Abort if a command exits unsuccessfully

  Output:
    -p                  Show project headers before output
    -v, --verbose       Show command error messages
    -j JOBS, --jobs=JOBS
                        number of commands to execute simultaneously

1.repo forall命令
 # repo forall -help
 # repo forall -c: 此命令遍历所有的git仓库,并在每个仓库执行-c所指定的命令,被执行的命令不限于git命令,而是任何被系统支持的命令,比如:ls, git log, git status等
2.repo forall -c使用
  # 切换分支
  # repo forall -c git checkout dev_test
  # 删除分支
  # repo forall -c git branch -D dev_test
  # 丢弃分支
  # repo forall -c git git reset —hard 提交ID(或最原始:HEAD)
  # repo forall -r framework/base/core -c git reset —hard 提交ID(或最原始HEAD)

  9.2 这里我修改vendor/widevine/Android.bp文件的内容,现在我要撤销掉。

10、一个用户(下图1)在project_two目录下新建一个honghua_branch分支,然后推送到服务器端。另外一个用户(下图2)可以通过repo sync来更新。

11、对于repo分支的理解:这里通过repo init -b <branch>,中的-b所指定的分支,是manifests的分支,不同分支,其中的文件清单内容有所不同。 下面repo init后面是有个-b选分支的。

12、project里面的revision属性:是修订的版本,通常指向一个具体的commitid,repo sync之后会checkout到该commitid,也可以是一个分支名称,如果是分支名称,则repo sync之后的代码是该分支。下面是在project_one 加入revision="honghua_2_branch",那么repo sync下代码之后project_one 下面的代码就是honghua_2_branch这个分支了。

 

13、清单文件manifest.xml中的default实体的revision属性,指定版本库默认的分支为revision属性值,该属性值做为repo sync之后工作目录中所有git项目的公共起点分支,也就是说,该manifest对应所有的git项目都有一个以revision属性值为名的分支,repo sync之后,在任意一个repo工作目录下的git库中,使用git branch或者repo start创建的分支,都是基于该git库中revision属性值为名的分支来创建。

       在下面的测试中,我定义default revision="honghua_2_branch" 设置一个默认的分支,然后没有在project path="project_two"里面指定分支。repo sync下来的到project_two路径是这个honghua_2_branch分支的代码。

14、<copyfile>标签  可以作为<project>标签的子标签,每一个<copyfile>标签表明了在repo sync的时候从src把文件拷贝到dest。 src相对于该project来说,dest相对于根目录来说。

15、添加新的git仓库方法,先在服务器端新建一个FotaUpdateApp.git仓库,然后再客户端把FotaUpdateApp目录push到这个路径,如图1。

      

修改xml文件,然后push到服务器,然后再客户端repo sync,就可以看到新apps目录了。

16、repo init  --mirror的时候提示(下图1) repo manifest . fatal: manifest 'default.xml' not available,解决方法是(下图2)repo init  后面必须带 --repo-url=ssh://git@xxxxxxx/home/git/tmp/repo-server/repo.git  

     

17、Manifest的2个属性值revision,upstream.

       revision:是修订的版本,通常指向一个具体的commitid,repo sync之后会checkout到该commitid,也可以是一个分支名称,如果是分支名称,则repo sync之后,checkout到当前分支最新commitid。
       upstream:是一个分支名称,和revision匹配,如果revision是分支名称,则upstream不起作用,如果revision是commitid,则upstream则是该commit对象所在的分支。

18、repo回退当前分支下所有仓库到指定日期前的最新代码版本.

git log --pretty=format:" "
控制显示的记录格式,常用的格式占位符写法及其代表的意义如下:

选项 说明
%H   提交对象(commit)的完整哈希字串
%h    提交对象的简短哈希字串
%T    树对象(tree)的完整哈希字串
%t    树对象的简短哈希字串
%P    父对象(parent)的完整哈希字串
%p    父对象的简短哈希字串
%an   作者(author)的名字
%ae   作者的电子邮件地址
%ad   作者修订日期(可以用 -date= 选项定制格式)
%ar   作者修订日期,按多久以前的方式显示
%cn   提交者(committer)的名字
%ce   提交者的电子邮件地址
%cd   提交日期
%cr   提交日期,按多久以前的方式显示
%s    提交说明

19、查看所有仓库某个时间段的log。

#!/bin/bash

for ((i=16; i>=16; i --))
do

  start=2021-12-$i
  #end=2021-12-$((b=i+1))
  end=2021-12-$i
  
  echo ***********************start=$start    end=$end***********************

  repo forall -c   git log  -1 --since=$start" 00:00" --until=$end" 24:00"
   
done

20、repo 服务器的IP地址变更后,需要执行repo init 新的服务器地址 后面加--config,然后就可以repo sync更新,各个git仓库的地址也会跟着变化。

repo init --repo-url=ssh://git@172.16.32.15/home/git/RK_Android_R/repo.git   -u  ssh://git@172.16.32.15/home/git/RK_Android_R/manifests_lenkor.git   -m  Android11.xml  --config

参考文章

repo回退当前分支下所有仓库到指定日期前的最新代码版本【转】 - 请给我倒杯茶 - 博客园

repo 基本使用_依然怡然-CSDN博客_repo使用

repo常用命令&代码提交流程_Gavin的博客-CSDN博客_repo命令

git push 和repo upload-----"no branches ready for upload"_armwind的专栏-CSDN博客_repo upload

Repo 使用详解 - 简书

repo新建分支_k663514387的博客-CSDN博客_repo 创建分支

repo 的几个使用理解 - 熊熊战队的老大 - 博客园

refs/remotes/m分支的含义_Android 系统开发-CSDN博客

repo manifest文件格式说明 - 简书

refs/remotes/m分支的含义_weixin_34289454的博客-CSDN博客

[GIT]Repo Manifest的3个属性值revision,upstream,dest-branch简介_小蜗牛之家-CSDN博客

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值