INNER CODE UNIT · Python

gitall

ryan4yin/knowledge · git/gitall.py:17

def gitall(args: List[str]):
    """
    遍历当前文件夹下所有的 git 仓库,在每个仓库中执行某个 git 命令.
    """
    for git_dir in Path(".").glob("**/.git"):
        print("-"*50)  # 分隔线
        git_root_dir = git_dir.parent

        cmd = ["git", *args]
        print(f"command: {cmd}, work_dir: {git_root_dir}")
        subprocess.run(cmd, cwd=git_root_dir)

if __name__ == "__main__":
    args_for_git = sys.argv[1:]
    gitall(args_for_git)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…