Re:Shellfirm: Intercept risky patterns at the command line
by pca006132 on Sunday July 31, 2022 @03:56AM
(#32294048)
iirc stash works more in a stack like manner? Say if you do git stash, and then do git rebase -i to clean up the history, proceed to write some other features, git stash again to clean it up, etc. Can you recover the files for the first stash?
[ Parent
| on HN ]
Re:Shellfirm: Intercept risky patterns at the command line
by Delk on Sunday July 31, 2022 @07:43AM
(#32294901)
Yes, you can. If you save, apply or pop with git stash with no arguments, it works like a stack by default, but you can also access the other entries. For example `git stash pop stash@{n}`, where n is the index of the entry in the stash "stack", applies the nth stash entry on top of the working tree and then removes it from the stored stashes. The latest entry is at index zero, so stash@{0} would be the last saved/pushed one.
You can see a list of saved stashes and their indices with `git stash list`.
Re:Shellfirm: Intercept risky patterns at the command line
by staindk on Sunday July 31, 2022 @08:56AM
(#32295200)
Ah you can use pop with other stashes too, thanks for the tip... though that feels a bit like a semantic misnomer (? unsure what term would be best to describe what I'm thinking - but 'pop' kind of feels like it should always be applicable only to the top element in a stack. I'd be scared that popping stash@{5} would apply all of stashes 1 to 5 at once lol).
I've been using `git stash apply stash@{n}`, which works just fine, but the stash is then not removed from your list and results in clutter.
Re:Shellfirm: Intercept risky patterns at the command line
by Delk on Sunday July 31, 2022 @12:22PM
(#32296596)
> though that feels a bit like a semantic misnomer
It does, but then, this is the git command-line interface. :)
My understanding is that the stash pop command is simply an apply plus the removal of the successfully applied stash. The man page reflects this. It does not pop everything above element in the list.