It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Stashing selected files

In SourceTree is it possible to stash only some (selected) files and not whole Working Copy?

What is the appropriate Git command?

4 answers

2 accepted

16 votes
Answer accepted

There are no straightforward ways to do it. The command-line solution in the Stackoverflow link in Seth's answer is useful, but I user my own trick in Sourcetree.

To stash select files:

  • Stage the files you want to stash
  • Then stash all files, but making sure that 'Keep staged changes' is checked.
  • Now you only have the files you want to stash in your current working copy.
  • Stash all files, with 'Keep staged changes' unchecked.

You can then re-apply the first stash, and discard the files that you wanted to stash.

Great answer. I am sure the command line options work but this was a question on how to do it in SourceTree. Thanks for providing a SourceTree solution

Like 2 people like this
3 votes
Answer accepted

There is a command line solution. Credit to: http://stackoverflow.com/questions/5506339/how-can-i-git-stash-a-specific-file

git stash --patch

Thank you, all the techniques in the article you linked could turn out useful.

Like 1 person likes this

I submitted a feature request for natively supporting stashing selected files:
https://jira.atlassian.com/browse/SRCTREEWIN-9103

L I'm New Here Feb 26, 2019

Hey everybody reading this should vote for this issue!

Like 1 person likes this

Mac users: please vote on the same feature request for the Mac version: https://jira.atlassian.com/browse/SRCTREE-4765

0 votes
Timothy Chin Community Leader Feb 13, 2014

Ctrl + click the files that you want to stash. You can google the other answer i guess.

I'm on a Mac. By the way:

- cmd + click: selects deselects a single file for further action

- shift + click: extends selection to that file for further action

- ctrl + click: opens contextual menu (same as right click)

- alt + click: does nothing more than normal left click

So on a Mac none of the previous serves the purpose.

I was asking the shell Git command because I'm not sure if it's even possible to do what I want to (= stash single files).

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted Jan 17, 2019 in Sourcetree

[dev team] Sourcetree for Windows 2019 Preview - Dark Theme

Hi folks, While the full post is over on our blog I'd like to share the dark theme we've got planned for 2019 here directly as well to keep the discussion going.  The ...

1,557 views 13 14
Join discussion

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