介绍
为了检查git repositores的git status
可以从仓库的根目录发出git status
。
C:\path\to\git_repositories\git_repo_1>git status On branch master Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean
如果一个目录包含多个,例如50个git存储库
C:\path\to\git_repositories>dir Directory of C:\path\to\git_repositories .ssh git_repo_1 ... git_repo_50 0 File(s) 51 Dir(s)
也不
C:\path\to\git_repositories>git status . fatal: Not a git repository (or any of the parent directories): .git
也不
C:\path\to\git_repositories>git status ./. fatal: Not a git repository (or any of the parent directories): .git
能够检查所有存储库的状态
题
如何一次检查所有git仓库的状态?
您可以使用for
循环更改为每个目录,做git status
,然后更改备份:
for /f "tokens=*" %a in ('dir /ad /b') do cd %a & git status & cd ..
如果在批处理文件中使用这个百分比,则需要将其加倍:
for /f "tokens=*" %%a in ('dir /ad /b') do cd %%a & git status & cd ..
编辑:
正如Cupcake所建议的,你可以这样做:
for /f "tokens=*" %a in ('dir /ad /b') do git --git-dir=%a/.git --work-tree=%a status
这感觉就像一个更强大和灵活的解决方案(例如,你可以更容易地使用存储在文本文件中的路径列表)。
我去了
find . -name .git -execdir git rev-parse --show-toplevel \; -execdir git status -s \;
我只需稍微调整就可以得到回购的名称,而不是整个路径。
我认为这是更好,因为对待目录递归。
如果你是一个工具家伙,你可以使用一个名为RepoZ的小助手,我最近写了(还在写)。
我在这里更详细地回答了一个非常类似的问题 。
以下是当前开发阶段的屏幕截图,希望您能看到对您有没有帮助:
如果你想知道那些字符串是什么意思,比如+45 ~403 -88
,它们是压缩状态字符串,告诉你是否有提交提取或者推送,以及是否在本地添加/修改/删除文件。 有关GitHub上的项目网站的更多详细信息
如果您有一个由多个Git存储库组成的系统,那么可能会创建一个Google repo
工具: https : //code.google.com/archive/p/git-repo/
如果你发现自己编写脚本来通过这些仓库来分发Git命令,你应该切换到repo
。
repo
与(不幸)XML文件一起工作,称为“manifest.xml”,它指定工作区中的Git存储库。 对于每个回购指定哪个分支和提交应该出现; 您可以使用repo
将Git存储库“钉”到特定版本,或者追踪磁头。
如果你有一个repo
工作区,那么
$ repo status
那么repo
将做你几乎要求的东西:迭代Git仓库,给你一个状态。