Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recursively check for git directory updates

Tags:

git

linux

ubuntu

I would like to know if there is a way to determine which sub-folders under a specified directory are git projects. After which, check which of those git projects need updating via 'git fetch' or otherwise.

For example, I have a folder called development in my home folder, which holds various projects with about 10% of them using git. Rather than individually check for project updates I would like to be able to run a command which checks for any updates for all of the git folders in the development directory.

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

like image 603
Emmanuel M. Smith Avatar asked Jan 12 '12 16:01

Emmanuel M. Smith


1 Answers

One way to get a list of all Git repos under your current directory is with the following command:

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

You could then feed this into a shell script which runs your command of choice in each repository, either by changing to the directory or by using Git’s --git-dir and --work-tree arguments.

like image 106
dhwthompson Avatar answered Oct 18 '22 03:10

dhwthompson