Created
March 13, 2019 15:37
-
-
Save jdforsythe/f248bf6c72fc020225cc3e315a32e922 to your computer and use it in GitHub Desktop.
Git rename stash alias
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
[alias] | |
rename-stash = "!_() { if [ -z \"$1\" ] || [ -z \"$2\" ]; then echo \"git rename-stash 0 NewName\" && echo \"\" && git stash list && exit 1; else stash=\"stash@{$1}\"; rev=$(git rev-parse \"${stash}\"); git stash drop \"${stash}\" || exit 1; git stash store -m \"$2\" \"$rev\" || exit 1; git stash list; fi }; _" |
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 | |
_() { | |
if [ -z "$1" ] || [ -z "$2" ]; then | |
echo "git rename-stash 0 NewName" && echo "" | |
git stash list | |
exit 1 | |
else | |
stash="stash@{$1}" | |
rev=$(git rev-parse "${stash}") | |
git stash drop "${stash}" || exit 1 | |
git stash store -m "$2" "$rev" || exit 1 | |
git stash list | |
fi | |
} | |
_ "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment