I'm using git stashes extensively. Sometimes it becomes annoying to type out stash@{3}
when, at first glance, a simple 3
should suffice. Is it possible to use the shorter reference somehow?
I know a solution with shell aliases. Making an alias like
sshow = "!f { git stash show @{$@}; }; f"
allows using git sshow 1
. It even allows passing additional arguments to git stash show
if $@
is expanded properly.
However, in this case git autocomplete does not work: when git stash show stash@{0} --<Tab><Tab>
is typed it should show all git diff
options, but here it knows nothing about the underlying command.
Are there other ways of making such alias which preserve original git diff
completion context?
Yes, this is built-in to Git as of v2.11. You can refer to any stash by index only. For example, to apply the stash at index 2 you can type
git stash apply 2