加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 一次检查所有git存储库的状态

发布时间:2020-12-14 02:54:44 所属栏目:Windows 来源:网络整理
导读:介绍 为了检查git repositores的状态,可以从存储库的根目录发出git status. C:pathtogit_repositoriesgit_repo_1git statusOn branch masterYour branch is up-to-date with 'origin/master'.nothing to commit,working directory clean 如果目录由多个
介绍

为了检查git repositores的状态,可以从存储库的根目录发出git status.

C:pathtogit_repositoriesgit_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:pathtogit_repositories>dir

 Directory of C:pathtogit_repositories

  .ssh
  git_repo_1
  ...
  git_repo_50
   0 File(s)
   51 Dir(s)

也不

C:pathtogit_repositories>git status .
fatal: Not a git repository (or any of the parent directories): .git

也不

C:pathtogit_repositories>git status ./.
fatal: Not a git repository (or any of the parent directories): .git

能够检查所有存储库的状态

如何一次检查所有git存储库的状态?

解决方法

您可以使用更改为每个目录的for循环,执行git状态,然后更改备份:

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

这感觉就像一个更健壮,更灵活的解决方案(例如,您可以更轻松地调整它以使用存储在文本文件中的路径列表).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读