-
-
Save tjarksaul/7a513d6e653c950fdd9030a4375e2fcf to your computer and use it in GitHub Desktop.
A custom script for git to stash any working changes, pull origin main, and unstash your working changes
This file contains 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 | |
stash() { | |
# check if we have uncommited changes to stash | |
git status --porcelain | grep "^." >/dev/null; | |
if [ $? -eq 0 ] | |
then | |
if git stash save -u "git-update on `date`"; | |
then | |
stash=1; | |
fi | |
fi | |
} | |
unstash() { | |
# check if we have uncommited change to restore from the stash | |
if [ $stash -eq 1 ] | |
then | |
git stash pop; | |
fi | |
} | |
stash=0; | |
stash; | |
git pull --rebase origin main; | |
unstash; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment