Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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

34 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 # people like this

SourceTree also has custom actions, I added a custom action 'Stash selected files', script target 'git.exe', parameters 'stash push $FILE', seems to work and slightly easier once you have te custom action.

Like # people like this

@Johan Scholten 
been a while, but how does the stash description is determined in this way?

It just uses the default now for me, something with the branch name included. Might be adaptable, never checked that.

You can also put parameters for a default name I guess, but there is no way in SourceTree to have a popup for filling in a name for the stash it seems.

5 votes
Answer accepted
Seth Rising Star Feb 20, 2014

There is a command line solution. Credit to:

git stash --patch

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

Like # people like this

I submitted a feature request for natively supporting stashing selected files:

Hey everybody reading this should vote for this issue!

Like Paul Strugnell likes this

Mac users: please vote on the same feature request for the Mac version:

Like # people like this
0 votes
Timothy Rising Star 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

Atlassian Community Events