【问题标题】:check recursevely if there git checked out files递归检查是否有 git 签出文件
【发布时间】:2021-07-21 14:31:14
【问题描述】:

我的所有项目都在一个名为 c:\Projects 的文件夹中。它们都是托管在 Bitbucket 上的 git 项目,我希望遍历所有这些文件夹并检查是否有需要推送的修改文件。有没有办法通过 PowerShell / cmd 行来做到这一点?

谢谢

【问题讨论】:

  • "...托管在 Bitbucket 上的 GitHub 项目。" :-D

标签: git powershell cmd


【解决方案1】:

我建议你使用简单的脚本:

$directory = "C:\users\turek\source\my_git_repos";
dir $directory -Directory | ForEach-Object { 
    cd $_.FullName;
    git status; 
};

或者,更复杂的版本,它不进入不是 git 存储库的目录:

$directory = "C:\users\turek\source\my_git_repos";
# gets all subdirectories and loops through them
dir $directory -Directory | ForEach-Object {
    # if the directory is git repo, then check the status
    if ( Test-Path -Path "$($_.FullName)\.git" ) {
        # switches directory
        cd $_.FullName;
        # gets GIT repo status 
        git status; 
    }
};

【讨论】:

    猜你喜欢
    • 2013-11-07
    • 1970-01-01
    • 2014-06-21
    • 1970-01-01
    • 1970-01-01
    • 2019-11-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多