windows - 更新Windows文件夹中的所有git repos

标签 windows git command-line

This答案是针对 linux 命令行的。我需要相同的 Windows 命令行。我使用 this 创建了以下内容,但我的代码不起作用。

for /D /r %i in (*.*) do (cd %i && echo %i && git pull && cd ..)

更新

根据@SevenEleven 的回答和@kostix 的评论,以下内容有效。

for /D %%i in (.\*) do (cd "%%i" && git pull && cd..)

for /D %%i in (*) do (cd "%%i" & git pull && cd..)

最佳答案

这应该可以完成工作:

for /D %%i in (.\*) do (cd %%i && echo %%i && git pull && cd ..)

此脚本搜索当前目录的子目录(for/D %%i in (.\*))。它更改到找到的每个目录 (cd %%i),将其名称写入控制台 (echo %%i) 并执行 git pull

/r 也会搜索所有子目录。由于您不想搜索项目子目录,因此不需要这样做。如果搜索绝对路径,则可以去掉 cd ..:

关于windows - 更新Windows文件夹中的所有git repos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33877138/

相关文章:

c++ - 您如何才能准确地看到内存泄漏的内容?

windows - SSH 和 SCP 失败,错误为 "CreateProcessW failed error:2 posix_spawn: No such file or directory"

git - 清除 git 本地缓存

command-line - openssl命令行验证签名

java - 从 Java 执行 CLI 命令

java - 设计命令行实用程序的包装器

Python ctypes.WinDLL 错误,找不到 _dlopen(self._name, mode)

windows - 批量字符串问题(搜索整行)

git - 列出可以安全删除的 git 分支

git - 从 ClearCase 迁移到 Git