Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git rename stash alias
[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 }; _"
#!/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