Reputation: 300
a repo with many branches might have one stash for each branch, ie, that many stashes, representing a wip on that branch. is there a way to switch to a branch and just apply the only stash for that branch, without having to select it first?
Upvotes: 1
Views: 161
Reputation: 488193
Stashes aren't on branches. (That's about half the point of a stash commit: since it's not on any branch, it is easy to use git stash
to "move" changes between branches. In the level at which git stash
works, branches are irrelevant—they don't even need to exist.)
What this really means is that there is no such one-to-one correspondence:
WIP on branch
.git stash
,1 this is probably a good idea.All that aside, the short answer is no. The command probably should have an easier way to search git stash list
output, but at least as of now (Git 2.24) it does not. See How to name and retrieve a stash by name in git? for numerous ways to write your own searcher.
1I recommend not using git stash
very much. It's way too easy to create a lot of them and then lose track of them, and they don't do anything you cannot do by making a regular commit. Remember, all git stash
does is make some commits that are on no branch. Each stash consists of either two or three commits, that are made in a way such that git stash apply
can use them, but a lot of the rest of Git can't use them very well.
Upvotes: 1