Last active
October 11, 2019 14:38
-
-
Save jancimajek/c744675a13da3357a7e9d3959b6b1d3b to your computer and use it in GitHub Desktop.
Smart rebase master
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 | |
# GITS: https://gist.github.com/jancimajek/c744675a13da3357a7e9d3959b6b1d3b | |
echo "[git fetch]" | |
git fetch | |
NEEDS_UPDATE=$(git log HEAD..origin/master --oneline | wc -l) | |
if [ $NEEDS_UPDATE -eq 0 ] | |
then | |
echo "Master already up to date, no need to update" | |
exit 0 | |
fi | |
GITWB=$(git rev-parse --abbrev-ref HEAD) | |
GITTS=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
STASH_MSG="YNCX WIP at ${GITTS}" | |
echo && echo "[git stash]" | |
git stash push -m "${STASH_MSG}" | |
echo && echo "[git checkout master]" | |
HUSKY_SKIP_HOOKS=1 git checkout master | |
echo && echo "[git pull -r]" | |
HUSKY_SKIP_HOOKS=1 git pull -r | |
echo && echo "[git checkout ${GITWB}]" | |
HUSKY_SKIP_HOOKS=1 git checkout "$GITWB" | |
echo && echo "[git rebase master]" | |
HUSKY_SKIP_HOOKS=1 git rebase master | |
git stash list | grep "^stash@{0}: On ${GITWB}: ${STASH_MSG}$" && echo && echo "[git stash pop]" && git stash pop | |
echo && echo '[yarn install --frozen-lockfile]' | |
cd ~/Projects/red-badger/one-pay-fx | |
yarn install --frozen-lockfile | |
echo && echo '[yarn clean build]' | |
cd ~/Projects/red-badger/one-pay-fx/shared | |
yarn clean | |
yarn compile | |
cd ~/Projects/red-badger/one-pay-fx/api | |
yarn clean | |
yarn compile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment