Skip to content

Instantly share code, notes, and snippets.

@Jim-Holmstroem
Last active August 29, 2015 14:14
Show Gist options
  • Save Jim-Holmstroem/fd11844c83d91052840a to your computer and use it in GitHub Desktop.
Save Jim-Holmstroem/fd11844c83d91052840a to your computer and use it in GitHub Desktop.
Push private repository with submodules to DEIS (assuming the repo already has been ``deis create projectname``'d)
#!/usr/bin/env bash
export GIT_FLAGS=$*
OLD_BRANCH="master" # $(git $GIT_FLAGS rev-parse --abbrev-ref HEAD)
echo $OLD_BRANCH
TEMP_BRANCH="deis_build"
git $GIT_FLAGS branch --force $TEMP_BRANCH && git $GIT_FLAGS checkout --force $TEMP_BRANCH
git $GIT_FLAGS submodule status | cut -d' ' -f3 | xargs --no-run-if-empty -I{} bash -c "git $GIT_FLAGS config -f .git/config --remove-section submodule.{}" && find -type f -name .git -o -type f -name .gitmodules | xargs --no-run-if-empty rm -f && rm -rf .git/modules/* && rm -f .git/index && git $GIT_FLAGS add -A && git $GIT_FLAGS commit -m"flattened" && git $GIT_FLAGS push deis $TEMP_BRANCH:master --force
MAIN_EXIT_CODE=$?
#cleanup
git $GIT_FLAGS checkout --force $OLD_BRANCH
git $GIT_FLAGS branch -D $TEMP_BRANCH
git $GIT_FLAGS submodule update --init --recursive
exit $MAIN_EXIT_CODE
@Jim-Holmstroem
Copy link
Author

how do you make this always work again, despite what state it was left in last time?

@Jim-Holmstroem
Copy link
Author

should always be used with a "wipe clean and re-clone" policy so that isn't effected by the previous state (especially after fails)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment