Skip to content

Instantly share code, notes, and snippets.

@bmmalone
Last active December 5, 2017 22:42
Show Gist options
  • Save bmmalone/7dbc980e7bea20ce1db1fc046e4f8314 to your computer and use it in GitHub Desktop.
Save bmmalone/7dbc980e7bea20ce1db1fc046e4f8314 to your computer and use it in GitHub Desktop.
Pull all of the git repos in the current working directory
#! /usr/bin/env bash
###
# This is `Zarat`'s comment to `leo`'s answer from this SO thread:
# https://stackoverflow.com/questions/3497123
#
# Plus some additional logic to checkout a branch, if specified
###
set -x # echo on
if [ $# -gt 0 ]
then
find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} checkout "$1" \;
fi
find . -mindepth 1 -maxdepth 1 -type d -print -exec git -C {} pull \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment