How to name and retrieve a stash by name in git? -
i under impression give stash name doing git stash save stashname, later on apply doing git stash apply stashname. seems in case happens stashname used stash description.
is there no way name stash? if not, recommend achieve equivalent functionality? have small stash periodically apply, don't want have hunt in git stash list actual stash number is.
you can find stash name using git's regular expression syntax addressing objects:
stash^{/<regex>} :/<regex> for example, when saving stash save name:
git stash save "guacamole sauce wip" ... can use regular expression address stash:
git stash apply stash^{/guacamo} this apply youngest stash matches regular expression guacamo. way, don't have know number stash @ in stack, have know name. there no terser syntax this, can create alias in .gitconfig file:
[alias] sshow = "!f() { git stash show stash^{/$*} -p; }; f" sapply = "!f() { git stash apply stash^{/$*}; }; f" you can use git sapply <regex> apply stash (without dropping).
can use git sshow <regex> show: files changed, insertions, , deletions
edit: props this stackoverflow answer on how use bash arguments in git aliases.
edit 2: answer used contain drop , list aliases, i've since removed them, since drop requires stash@{n} syntax while list didn't filter stashes @ all. if knows how resolve stash sha-1 hash stash ref, implement other commands well.
edit 3: per isyi's suggestion i've added patch flag show contents of stash when showing one.
Comments
Post a Comment