![디렉터리를 통한 Windows for 루프, git pull을 실행하시겠습니까?](https://rvso.com/image/1444039/%EB%94%94%EB%A0%89%ED%84%B0%EB%A6%AC%EB%A5%BC%20%ED%86%B5%ED%95%9C%20Windows%20for%20%EB%A3%A8%ED%94%84%2C%20git%20pull%EC%9D%84%20%EC%8B%A4%ED%96%89%ED%95%98%EC%8B%9C%EA%B2%A0%EC%8A%B5%EB%8B%88%EA%B9%8C%3F.png)
Bash에서는 간단합니다.
for d in *; do GIT_DIR="$d/.git" git pull; done
또는:
for d in *; do GIT_DIR="$PWD/$d/.git" git pull; done
그러나 Windows 명령 프롬프트에서는 그다지 간단하지 않습니다. 난 노력 했어:
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"
그러나 아무것도 작동하지 않습니다. 항상 다음 오류 중 하나가 발생합니다.
fatal: unable to access '"repo-name/.git" /config': Invalid argument
The system cannot find the path specified.
답변1
이것은 CMD의 배치 파일에서 작동합니다.
for /d %%i in (*.*) do cd %%i & git pull & cd..
답변2
Powershell에서는 간단한 한 줄로 작성할 수 없나요?
예:
Resolve-Path D:\work\repos\*\.git | foreach { cd $_; git pull }
답변3
powershell
에 들어가다탐색기 주소 필드당신의기본 폴더그리고Enter 키를 누르세요. 그런 다음 다음을 실행합니다.
Get-ChildItem . -exclude *.ps1,temp,*.txt | foreach { cd $_; Write-Host "`r`n" $_; Git pull '-v' }
Resolve-Path
귀하에게 적합하지 않은 경우 이 접근 방식을 사용하십시오 .
답변4
git pull <repository>
대신 Git Shell에서 cmd.exe
기본 쉘 설정으로 구문을 사용하고 루프 내부에서 setlocal enabledelayedexpansion
변수 초기화( set
) 를 찾는 것이 좋습니다 for
.