android repo命令,Android repo技巧:在源码中执行repo forall -c时列出git仓库名称

Android 源码使用 repo 命令来管理所有 git 仓库,当使用 repo forall -c 命令在所有 git 仓库上执行指定的 git 命令时,默认不会列出每个git 仓库的 project 名称。

例如使用 repo forall -c git status 命令来查看各个 git 仓库的改动时,打印出来的内容没有包含仓库的路径名,有时候根本看不出来某些改动发生在哪个仓库下。

如果想要打印出 git 仓库的名称,可以使用 repo forall 的 -p 选项。查看 repo help forall 命令打印的帮助信息,对 -p 选项说明如下:

-p

Show project headers before output

根据帮助信息里面的例子,建议先写 -p,再写 -c,即 repo forall -p -c,执行该命令,会打印类似下面的信息:

$ repo forall -p -c git pull

project buildroot/

Already up-to-date.

project tools/

Already up-to-date.

可以看到,它先打印 git仓库信息 “project buildroot/”,再打印该仓库的状态。

如果不加 -p 选项, 执行 repo forall -c git pull 命令,只会打印下面的信息:

$ repo forall -c git pull

Already up-to-date.

Already up-to-date.

可以看到,只提示 “Already up-to-date.”,没有说明是哪个仓库,如果某个仓库更新代码,比较难知道是哪个仓库更新了代码。相比之下,加了 -p 选项的打印了 git 仓库信息,比较直观。

注意:实际使用中遇到了使用 -p 选项没有打印一些报错信息的例子,具体描述如下,下面在 # 后面的内容是注释说明,不是命令内容的一部分。

$ ls # 下面的 brandy 目录是后来新增的,原先的repo没有跟踪这个仓库

brandy buildroot tools

$ repo forall -c git pull # 执行该命令,会看到报错信息,提示有个仓库没有指定

fatal: No remote repository specified. Please, specify either a URL or a

remote name from which new revisions should be fetched.

Already up-to-date.

Already up-to-date.

Already up-to-date.

$ repo forall -p -c git pull

project buildroot/

Already up-to-date.

project tools/

Already up-to-date.

上面的 repo forall -p -c git pull 命令,加了 -p 选项,没有看到打印 “fatal: No remote repository specified” 的报错信息,应该是被过滤掉了。

可见,使用 -p 选项可能会漏掉某些报错信息。但不加 -p 又打印不出具体的仓库名字。所以要根据实际情况来选择是否使用 -p 选项。

如果仓库 project 不经常发生变动,可以使用 -p 选项。确认新增仓库 project 时,先不加 -p 选项,更新代码,下载好新的 project 后,就可以继续使用 -p 选项。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值