How to apply files from stash selectively?

How can I apply files inside a stash selectively? Rather than right-clicking on the stash and applying it in its entirety?

5 answers

1 accepted

Unfortunately git stash doesn't support doing this. You basically have to apply the stash, then only stage the parts that you want to commit. You can then re-stash the remainder (or discard it).

ok so the following commandline feature isn't in the SourceTree roadmap yet?

$ git checkout stash@{0} -- <filename>

Git itself does support this.

As stated above, git naturally supports this via

$ git checkout stash@{0} -- <filename>

You can even show the stashed version and save it under a different name:

$ git show stash@{0}:<full/filename>  >  <newfile>

Git is just powerfil like that. :-)

I would love to see the stash feature extended to include these usages in SourceTree.

any updates on this? Cannot find how to apply only certain files/chunks from git stash. I used that on other project with TortoiseHg and like it. Can't find how to do same with sourcetree.

Perhaps no way to do it while applying the stash (that would be nice).
But you can achieve the affect by applying the stash, and then stashing just the hunks that you don't want (leaving the bits/files you do).

 

Command line equivalent is:

git stash pop stash@{x}
git stash -p

Is there a JIRA issue we can vote on for this?

BTW: You can see here (http://stackoverflow.com/a/22555169/40064) how to do it manually.

Recently I looked up `custom actions` but they aren't an option that is available when right-clicking on anything related to a stash.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

649 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you