Skip to content

Instantly share code, notes, and snippets.

@dominicthomas
Created March 23, 2016 17:52
Show Gist options
  • Save dominicthomas/2a971fb53186b1966651 to your computer and use it in GitHub Desktop.
Save dominicthomas/2a971fb53186b1966651 to your computer and use it in GitHub Desktop.
Useful script to checkout and pull new changes on develop for a repo and all submodules... This will need to be adapted to the environment it is required in.
#/bin/bash
cd $1
if [ -d $1 ]; then
echo "Changing Directory too: " $1
else
echo "Directory does not exist"
exit 1
fi
git fetch --all
git checkout develop
git pull origin develop
git submodule foreach 'git checkout develop'
git submodule foreach 'git fetch'
git submodule foreach 'git pull origin develop'
git status
# For specific cases only:
# Submodule commit hash changes after merge of main into develop
if [ -n "$(git status --porcelain)" ]; then
echo "There are changes!";
echo "Commit and push hash changes (y/n)?"
read x
if [ "$x" = "y" ]; then
git add .
git commit -m "Updating hashes"
git push origin develop
else
exit 1
fi
else
echo "No changes!";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment