Run git pull over all subdirectories
This question already has an answer here:
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 ;
To clarify:
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 To play around with find, I recommend using echo
after -exec
to preview, eg:
find . -type d -depth 1 -exec echo git --git-dir={}/.git --work-tree=$PWD/{} status ;
Note: if the -depth 1
option is not available, try -mindepth 1 -maxdepth 1
.
ls | xargs -I{} git -C {} pull
并行执行:
ls | xargs -P10 -I{} git -C {} pull
A bit more low-tech than leo's solution:
for i in */.git; do ( echo $i; cd $i/..; git pull; ); done
This will update all Git repositories in your working directory. No need to explicitly list their names ("cms", "admin", "chart"). The "cd" command only affects a subshell (spawned using the parenthesis).
链接地址: http://www.djcxy.com/p/92372.html上一篇: Git diff表示子项目很脏
下一篇: 运行git pull遍历所有子目录