运行git拉过来的所有子目录 [英] Run git pull over all subdirectories

查看:93
本文介绍了运行git拉过来的所有子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何更新他们的共同父母的目录中的多个项目的Git仓库,而不 CD ING到每个回购的根目录?我有一个都是独立的Git仓库(不可以子模块)以下内容:

How can I update multiple git repositories from their shared parent's directory without cd'ing into each repo's root directory? I have the following which are all separate git repositories (not submodules):

/plugins/cms
/plugins/admin
/plugins/chart

我要更新一次全部或至少简化我当前的工作流:

I want to update them all at once or at least simplify my current workflow:

cd ~/plugins/admin
git pull origin master
cd ../chart
git pull

等。

推荐答案

运行从父目录下面,插件在这种情况下:

Run the following from the parent directory, plugins in this case:

find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=$PWD/{} pull origin master \;

要澄清:


  • 找到。搜索当前目录

  • 型ð找目录,而不是文件

  • -depth 1 的一个子目录的最大深度

  • -exec {} \\; 运行,每一个自定义命令找到

  • 混帐--git-DIR = {} /。混帐 - 共同努力树= $ PWD / {}拉 git的拉动各个目录

  • find . searches the current directory
  • -type d to find directories, not files
  • -depth 1 for a maximum depth of one sub-directory
  • -exec {} \; runs a custom command for every find
  • git --git-dir={}/.git --work-tree=$PWD/{} pull git pulls the individual directories

要玩弄的发现,我建议使用回声 -exec 来preVIEW,例如:

To play around with find, I recommend using echo after -exec to preview, e.g.:

find . -type d -depth 1 -exec echo git --git-dir={}/.git --work-tree=$PWD/{} status \;

请注意:如果 -depth 1 选项不可用,请尝试 -mindepth 1 -maxdepth 1

Note: if the -depth 1 option is not available, try -mindepth 1 -maxdepth 1.

这篇关于运行git拉过来的所有子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆