Skip to content

Instantly share code, notes, and snippets.

@jdforsythe
Created March 13, 2019 15:37
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdforsythe/f248bf6c72fc020225cc3e315a32e922 to your computer and use it in GitHub Desktop.
Save jdforsythe/f248bf6c72fc020225cc3e315a32e922 to your computer and use it in GitHub Desktop.
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