Kazunori Takaishi
Kazunori Takaishi

Reputation: 2398

Git: How to unstash specific files in SourceTree?

I often use Atlassian'Sourcetree. It's really helpful GUI Git Client. But when I want to unstash specific files, Sourcetree'stash just apply all stashed changes. What I want to do is unstash selected files in SourceTree just like the following git command git checkout stash@{0} <filename>

Does anyone know how to do this?

Upvotes: 10

Views: 11151

Answers (1)

Jo&#227;o Mendes
Jo&#227;o Mendes

Reputation: 1435

This is a fairly old question, but it popped up on my google search, so here's a partial answer.

To stash select files:

  1. Stage the files you want to stash.
  2. Then stash all files, but making sure that 'Keep staged changes' is checked.
  3. Now you only have the files you want to stash in your current working copy.
  4. Stash all files, with 'Keep staged changes' unchecked.
  5. You can then re-apply the first stash, and discard the files that you wanted to stash.

From here. Kind of awkward, but it is what it is.

I suppose what I would do is apply the whole stash without deleting it, use the above procedure to stash only the files you want to apply, discard everything, then apply the partial stash you built.

On the command line, you could probably short-cut a few steps, I suppose...

Upvotes: 9

Related Questions