我的机器上有几个项目文件夹,都包含一个.git
目录。我假设所有程序员都处于这种情况,他们忘记了将某些东西推送到服务器。那么有没有办法搜索所有子目录中的未提交/未提交的更改并列出它们?
以下是我的情况示例:
MainFolder
|
|-Project1
| |-.git # containing uncommitted changes
| |-index.php
| |-page_one.php
|
|-Project2
| |-.git # This git-status is clean
| |-index.php
| |-another_page.php
|
|-Project3
| |-.git # containing unstaged changes
| |-index.php
| |-some_page.php
|
|-Project4
|-.git # containing uncommited changes
|-index.php
|-some_page.php
我想要一个清单,说:
You need to check these .git-files:
- MainFolder/Project1/.git
- MainFolder/Project3/.git
- MainFolder/Project4/.git
答案 0 :(得分:2)
find
能做你想做的吗?
find MainFolder -name .git -print -execdir git status \;
-name <pattern>
您要搜索的模式-print
打印出所有匹配-execdir <command>
;需要使用尾随分号,并且需要进行转义,以在find循环中构建命令更详细的信息可以在man page。
中找到答案 1 :(得分:1)
我有一个用于执行此操作的小bash脚本。它不会让你获得你之后的树,但它会告诉你git repo以及是否有任何未提交的更改。
function runCmd
{
echo `basename $dir` "repository:"
eval $@
echo
}
for dir in `ls -d */`
do
pushd $dir >> /dev/null
if [ -d ".git" ]
then
runCmd $@
fi
popd >> /dev/null
done
将其保存在名为allRepo的文件中。然后,您可以从文件树的顶层运行所需的任何命令:
allRepo git fetch
allRepo git status
这个脚本很好,因为它不仅限于git命令。
答案 2 :(得分:0)
您是否使用'Copy PNs that are out of line and paste them in the correct column
Dim N As Long, i As Long, j As Long
Set ws1 = Worksheets("KDLSA")
N = ws1.Cells(Rows.Count, "C").End(xlUp).Row
j = 4
For Each cell In Range("D2:F" & ws1.Cells(Rows.Count, "F").End(xlUp).Row)
If cell.Value = "" Then 'if cell C is blank, I want to shift the text to fill column C
ws1.Range("C" & j).Value = ws1.Range("D" & cell.Row).Value 'copy PN in column E to column D - this needs to be more robust to cover my range of columns rather than just D and E
j = j + 1
End If
Next cell
(或其变体locate
或mlocate
)并定期更新slocate
?我使用以下脚本:
locate.db
PS。 locate -b \*.git | sed 's!/\.git$!!'| while read d; do
test -d "$d"/.git || continue
cd "$d" && test -n "`git status --short`" && echo "$d"
done
可以返回裸(locate
)和非裸(xxx.git
)目录,因此我剥离xxx/.git
并仅测试非裸存储库。
答案 3 :(得分:0)
find /Mainfolder -name ".git" -type d | awk -F\/ '{ printf "cd ";for ( i=2;i<=NF-1;i++ ) { printf "%s/",$i } printf "; git status | grep -q \"new file\" && echo \"$(pwd) Needs checking\""}' | sh
在一行中使用find with awk,找到由git控制的所有目录,然后使用awk构建目录名。然后打印并执行git-status,结果为&#34;新文件&#34; grepped。然后通过sh管道这个构造的命令来执行它。
文字&#34;新文件&#34;需要相应更改。
输出:
/Mainfolder/Project1 Needs checking