Skip to content

Instantly share code, notes, and snippets.

@ftorto
Created January 24, 2017 10:21
Show Gist options
  • Save ftorto/641ced2c03950d715b7b259dbec4ffa3 to your computer and use it in GitHub Desktop.
Save ftorto/641ced2c03950d715b7b259dbec4ffa3 to your computer and use it in GitHub Desktop.
Apply a GIT command to all subfolder
#!/bin/sh
#Git recursive
# Apply a command to all sub git directories
rootpath=.
cmd=$*
CLREOL=$'\x1B[K\033[0m'
for d in `find . -maxdepth 2 -type d -name .git | sed 's@./@@; s@/.git@@'`
do
echo -e "\033[4m${rootpath}/$d\033[0m"
cd $d > /dev/null;
$cmd
echo -e "\n";
cd - > /dev/null;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment