简介
本地某文件夹下有几十个git仓库,执行脚本一次性全部git pull。
脚本
# 定义要遍历的文件夹路径
$folderPath = "x:\loda"
 
# 使用Get-ChildItem遍历文件夹
Get-ChildItem -Path $folderPath | ForEach-Object {
    	# 输出每个项的完整路径
	# Write-Host $_.FullName
	
	$target = get-item $_.FullName
	if($target.PSIsContainer) {
		Get-ChildItem -Path $_.FullName | ForEach-Object {
    		
			$target = get-item $_.FullName
			if($target.PSIsContainer) {
				# it's a folder
				
				Write-Host $_.FullName
				$gitpath = $_.FullName + "\.git"
				$isgitfolder = Test-Path -Path $gitpath
				if($isgitfolder){
					Write-Host $_.FullName
					cd $_.FullName
					git pull
				}
				
			}
		}
	}
}
    黑夜里不停折腾的代码行者。
                    
                

                
            
        
浙公网安备 33010602011771号