Created
March 12, 2013 15:10
-
-
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 .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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