如何在Windows上git pull for multiple repos?

ROO*_*DAY 12 windows git bash github

所以我有很多回购,有时候我会忘记一些人是否落后于他们,所以我想知道有一种方法可以在一个.bat脚本中为每个仓库提供git pull.我看到有人为linux做了我相信这里,但我在一台Windows机器上.有谁知道如何为Windows做这个?

eik*_*ooc 21

您可以创建一个.bat文件,在其中使用此文件自行添加所有存储库

cd C:\path\to\git\repo
call git pull
cd C:\path\to\git\repo2
call git pull
Run Code Online (Sandbox Code Playgroud)

或者让它通过git存储库运行整个目录

FOR /D %G in (C:\Documents\GitRepos\*) Do cd %G & call git pull & cd ..
Run Code Online (Sandbox Code Playgroud)

而不是.bat文件,有一个用于Windows的GUI客户端Github

如果您拥有所有存储库,那么记住将它们全部同步并不是一件痛苦的事.


Ahm*_*gdy 8

这是PowerShell版本

Get-ChildItem -Directory | foreach { Write-Host "`n? Getting latest for $_ ?" | git -C $_.FullName pull --all --recurse-submodules --verbose }
Run Code Online (Sandbox Code Playgroud)


haw*_*eye 5

我真的很喜欢@eikooc的答案-希望它能正常工作-但在Windows 10上它对我不起作用。

这是我的变化形式:

for /f %%f in ('dir /ad /b C:\Documents\GitRepos\') do cd /d C:\Documents\GitRepos\%%f & call git pull & cd ..
Run Code Online (Sandbox Code Playgroud)