运行git pull遍历所有子目录
这个问题在这里已经有了答案:
在这种情况下从父目录, plugins运行以下内容:
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master ;
澄清:
find . 搜索当前目录 -type d来查找目录,而不是文件 -depth 1表示一个子目录的最大深度 -exec {} ; 为每个查找运行自定义命令 git --git-dir={}/.git --work-tree=$PWD/{} pull git pulls个人目录 为了玩弄find,我建议在-exec后使用echo来预览,例如:
find . -type d -depth 1 -exec echo git --git-dir={}/.git --work-tree=$PWD/{} status ;
注意:如果-depth 1选项不可用,请尝试-mindepth 1 -maxdepth 1 。
ls | xargs -I{} git -C {} pull
并行执行:
ls | xargs -P10 -I{} git -C {} pull
比利奥的解决方案更低技术:
for i in */.git; do ( echo $i; cd $i/..; git pull; ); done
这将更新工作目录中的所有Git存储库。 不需要明确列出他们的名字(“cms”,“admin”,“chart”)。 “cd”命令只影响一个子shell(使用圆括号产生)。
链接地址: http://www.djcxy.com/p/92371.html