Creates a backup of your uncommitted 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 | |
set -e | |
old_stash_count=$(git stash list | wc -l) | |
git stash push --keep-index --include-untracked --quiet | |
if test "$old_stash_count" == "$(git stash list | wc -l)"; then | |
echo "All changes have been committed." | |
exit 0 | |
fi | |
if test "$(git rev-parse 'autosave':)" == "$(git rev-parse 'stash@{0}':)"; then | |
echo "Tree is identical to last autosave." | |
else | |
git tag -f "$(date +'autosave-%Y%m-%d%H%M')" 'stash@{0}' | |
git branch -f 'autosave' 'stash@{0}' | |
echo -n "Autosaved at: " | |
git rev-parse --short=7 'stash@{0}' | |
fi | |
git stash pop --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment