repo_status

WangYangkai / 2024-11-13 / 原文

repo_status


if repo status command report error, use repo_status script:

#!/bin/bash

# 遍历当前文件夹下所有包含 .git 的目录
for dir in $(find . -type d -name .git); do
    # 获取 .git 所在的父目录
    parent_dir=$(dirname "$dir")
    
    # 切换到 .git 所在的父目录
    cd "$parent_dir" || exit
    
    # 执行 git status
    echo "git status in $parent_dir"
    git branch -v
    git status
    echo -e "\n"

    # 返回到脚本所在的目录
    cd - > /dev/null || exit
done