How to git pull for multiple repos on windows?

后端 未结 4 1094
遇见更好的自我
遇见更好的自我 2020-12-31 08:34

So I have a lot of repos, and sometimes I forget if some are behind on their pulls, so I was wondering there was a way to git pull for each repo in one .bat script. I saw so

相关标签:
4条回答
  • 2020-12-31 09:19

    You can make a .bat file in which you add all the repositories yourself with this

    cd C:\path\to\git\repo
    call git pull
    cd C:\path\to\git\repo2
    call git pull
    

    Or let it run through a whole directory with git repositories

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

    Instead of .bat file there is a GUI client Github for windows

    If you have all your repositories in there it won't be a pain to remember to sync them all.

    0 讨论(0)
  • 2020-12-31 09:25

    If you got Git installed with MinGW (bash) you can execute this command that works in parallel.

     ls -d **/* | xargs -P10 -I{} git -C {} pull
    
    0 讨论(0)
  • 2020-12-31 09:37

    I really liked @eikooc 's answer - and wanted it to work - but it wouldn't work for me on Windows 10.

    Here is my variation:

    for /f %%f in ('dir /ad /b C:\Documents\GitRepos\') do cd /d C:\Documents\GitRepos\%%f & call git pull & cd ..
    
    0 讨论(0)
  • 2020-12-31 09:39

    Here is a PowerShell version

    Get-ChildItem -Directory | foreach { Write-Host "`n■ Getting latest for $_ ↓" | git -C $_.FullName pull --all --recurse-submodules --verbose }
    
    0 讨论(0)
提交回复
热议问题