可以为子文件夹中的所有存储库做git状态吗?

问题描述 投票:0回答:7

我经常想检查发生了什么,特别是我想要一个命令,该命令列出了所有已更改的子文件夹的输出。有人知道解决方案吗? (顺便说一下,我在Mac OSX上)。

如果您需要递归(如果不这样做,也会工作):

git status

对于每个名称的目录
macos git bash subdirectory
7个回答
22
投票
将从包含它的目录中执行

.git

git status
)。哇,正是你想要的。

您也可以附加

-execdir
,以免在GIT项目的子目录中进一步提高效率(但可能会跳过Git subsodules,我没有想法,我没有想法,我从未使用过它们):
-prune
    

在每个目录上介绍,并分别使用Commandline选项

find . -name .git -type d -execdir git status \; -prune

.git

设置工作目录和
--work-tree
目录:

6
投票
--git-dir


for x in *; do git --work-tree="$x" --git-dir="$x/.git" status; done
Where:

**/*= subdiretory
中的每个文件
* = root diretory中的每个文件

4
投票
我在这里尝试了所有建议,但由于各种原因,它们都不对我有用。

这就是我的个人资料中所拥有的,我经常使用它。

git status **/* *
  • 代码文件中的Snippets很容易用“”。命令,例如:
  • gitr () { for f in $(find . -type d -name .git | awk -F"/.git$" '{print $1}'); do echo echo "................................ (cd $f && git $*) ........................................." echo (cd $f && git $*) done }
然后我可以跑

4
投票
. gitr.sh # file containing gitr() function, if not in a profile file

我得到了类似的东西:

gitr status
or

................................ (cd ./dir0 && git status) ......................................... On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean ................................ (cd ./dir1 && git status) ......................................... On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean ................................ (cd ./dir2 && git status) ......................................... On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean ................................ (cd . && git status) ......................................... On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean
or

gitr log -c 1
    

gitr rev-parse --abbrev-ref HEAD
它递归起作用。您可以为您的要求更改
find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \;

maxdepth
    

该代码将为子目录提供一个名称并显示紧凑的状态:
mindepth

1
投票
您可以创建一个脚本。也许也只是将其作为函数和位置创建。

ls | xargs -i sh -c 'echo _______ {} ______ && cd {} && git status -s -uno && cd .. '

将其放在主文件夹中并运行
.bash_profile

如果您的存储库是统一的,您可以做一些事情:

1
投票
#!/bin/bash REPOS=(GitRepoA GitRepoB GitRepoC AnotherRepoA) for R in "${REPOS[@]}"; do echo "Checking repo $R." pushd "$R" >/dev/null && { git status popd >/dev/null } done

或也许只是
bash script_name.sh
仅作为功能:

0
投票
shopt -s nullglob REPOS=(GitRepo{A..Z} AnotherRepoA)


i通过编写shell脚本
Mgit
来处理此内容,该脚本读取了当前目录中的隐藏文件.mgit,其中包含单个git存储库的文件夹列表。它做类似的事情:

shopt -s nullglob REPOS=(*)
    

trory git状态-u all。

这将列出所有修改和未跟踪的文件,直到所有子文件夹的叶节点保持基本根为当前工作目录
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.