Skip to content

Instantly share code, notes, and snippets.

@MrLotU
Created June 28, 2020 09:38
Show Gist options
  • Save MrLotU/da5dc3c7863a64cbe665f7304f4640c8 to your computer and use it in GitHub Desktop.
Save MrLotU/da5dc3c7863a64cbe665f7304f4640c8 to your computer and use it in GitHub Desktop.
Pull all GIT subdirectories from current directory.
subpull() {
BASEPWD="${PWD}"
for d in `find . -type d -depth 1`; do
cd "${BASEPWD}"
cd "${d}"
GIT_STATUS="$(git status 2>&1)"
if [[ $GIT_STATUS == *"not a git repository"* ]]
then
echo "${d} is not under git control. Skipping"
continue
fi
echo "${d}:"
if [[ "$*" == *--master* ]]
then
git checkout master
fi
git pull
done
cd "${BASEPWD}"
if [[ "$*" == *--open* ]]
then
xed .
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment