Skip to content

Instantly share code, notes, and snippets.

@jstanley0
Created March 12, 2013 15:10
Show Gist options
  • Save jstanley0/5143692 to your computer and use it in GitHub Desktop.
Save jstanley0/5143692 to your computer and use it in GitHub Desktop.
searches for git repositories under the given directory and resets them to the latest master e.g., to reset all plugins to the latest: git_nuke.sh vendor/plugins or to reset the current repository and all git repos under it: git_nuke.sh .
#!/bin/bash
if [ -z $1 ]
then
echo "this thing will reset all nested git repos to HEAD/master"
echo "specify a starting point"
exit 1
fi
if [ -d $1 ]
then
repos=`find $1 -name .git`
for repo in $repos
do
repo=`dirname $repo`
echo " * resetting $repo..."
pushd $repo >/dev/null
git checkout master
git reset --hard origin/HEAD
git pull
popd >/dev/null
done
else
echo "Specify a starting directory"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment