![Windows para percorrer diretórios, execute git pull?](https://rvso.com/image/1444039/Windows%20para%20percorrer%20diret%C3%B3rios%2C%20execute%20git%20pull%3F.png)
No Bash é simples:
for d in *; do GIT_DIR="$d/.git" git pull; done
Ou:
for d in *; do GIT_DIR="$PWD/$d/.git" git pull; done
No entanto, no prompt de comando do Windows, não é tão simples. Eu tentei:
for /D %i in (*.*) do cd "%i" && git pull
for /D %i in (*.*) do cd "<absolute_path>\%i" && git pull
for /D %i in (*.*) do set GIT_DIR="<absolute_path>\%i\.git git pull"
for /D %i in (*.*) do set GIT_DIR="<absolute_path>\%i\.git && git pull"
Mas nenhum funciona. Sempre recebendo um destes erros:
fatal: unable to access '"repo-name/.git" /config': Invalid argument
The system cannot find the path specified.
Responder1
Isso funciona para mim em um arquivo em lote no CMD:
for /d %%i in (*.*) do cd %%i & git pull & cd..
Responder2
Isso não poderia ser uma simples linha no Powershell?
Exemplo:
Resolve-Path D:\work\repos\*\.git | foreach { cd $_; git pull }
Responder3
Entrar powershell
emCampo de endereço do Explorerdo seupasta baseepressione Enter. Em seguida, execute:
Get-ChildItem . -exclude *.ps1,temp,*.txt | foreach { cd $_; Write-Host "`r`n" $_; Git pull '-v' }
Use esta abordagem, se Resolve-Path
não funcionar para você.
Responder4
Sugiro usar git pull <repository>
sintaxe no Git Shell com cmd.exe
configuração de shell padrão e procurar setlocal enabledelayedexpansion
inicialização de variável ( set
) dentro for
do loop.