Last active
August 29, 2015 14:14
-
-
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)
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
#!/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 |
adds support for push_submodule_to_DEIS.sh -C "gitrepo"
(or any arbitrary general git argument) but it should still be backwards compat
xargs --no-run-if-empty
always rm -f
incase missing
how do you make this always work again, despite what state it was left in last time?
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
Note that this command will remove any uncommited files (and probably unstaged as well)