Skip to content

Instantly share code, notes, and snippets.

@Invertisment
Created June 21, 2017 08:00
Show Gist options
  • Save Invertisment/d3cd4b1a0056902219261cded567b5cf to your computer and use it in GitHub Desktop.
Save Invertisment/d3cd4b1a0056902219261cded567b5cf to your computer and use it in GitHub Desktop.
Git script for managing nested repos
#!/bin/bash
#
# recursively finds all git repos (2 levels deep) and executes given git command on them
# omits .ws .git and .idea directories
#
# example: bash gitAll.sh pull
# result: pull from all repos
#
find . -not -regex '.*\(.git\|.idea\|.ws\).*' \
-maxdepth 2 -mindepth 2 -type d \
-exec echo {} \; \
-exec git --git-dir={}/.git --work-tree=$PWD/{} $@ \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment