Recursively check for git directory updates

I would like to know if there is a way to determine which subfolders in the specified directory are git projects. Then check which of these git projects need to be updated via 'git fetch' or otherwise.

For example, I have a folder named development in my home folder that stores various projects with about 10% of them using git. Instead of individually checking for project updates, I would like to be able to run a command that checks for any updates for all git folders in the development directory.

It would be nice if he could update non-conflicting projects.

+5
source share
4 answers

Git - :

find . -name '.git' | xargs -n 1 dirname

script, , Git s --git-dir --work-tree.

+3

() :

back=`pwd`; for d in `find . -type d -name .git` ; do cd "$d/.."; git pull ; cd $back ; done
+3

Take a look at android repo . I think that there is nothing special about it, and you can adapt it to your needs.

+1
source

In short:

find . -name .git -execdir git pull -v ';'

You can also create the following script (for example update_src.sh):

#!/bin/sh
# Script to pull all git repositories to the recent version.
ROOT=$(git rev-parse --show-toplevel 2> /dev/null)
find "$ROOT" -name .git -type d -execdir git pull -v ';'

or create the following alias in the shell:

alias git-pull-all='find $(git rev-parse --show-toplevel 2> /dev/null) -name .git -type d -execdir git pull -v ";"'

or c ~/.gitconfig.

+1
source

All Articles