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

Discard stashed hunk -- how to get it working?

Does unstashing individual hunks actually work? This consistently fails on every git repo on my Mac.


1. Checkout a repo.

2. Make some changes. (even just 1 tiny change)

3. Stash changes.

4. View the Stash.

5. Press "Discard Hunk" on any hunk.

Expected: discard the hunk.

Actual: the attached error message.

Question: Am I doing something wrong, or is this feature just broken out of the box?

1 answer

1 accepted

0 votes
Answer accepted

I don't think you can modify stashes in this way. SourceTree always displays the "Discard Hunk" and related buttons in the diff view, even though they aren't relevant here.

The reason for this is that all of those types of changes (discarding hunks or file changes) are performed on your working copy, but your stash is, by definition, not on your working copy.

To get what you want, you should apply the stash to a clean working copy, make the modifications you want, then create a new stash.

You may consider filing a bug at jira.atlassian.comrequesting that the developers remove/disable those buttons when viewing stashed diffs. If so, answer this question with a link so others can vote it up if they want to.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Summit

Don't miss out: Upcoming AMAs with Atlassian's Remote Summit 2020 Superstars!

Hello Community members! Remote Summit 2020 was a blast. And without those long walks from one side of the Mandalay Bay to the other, everyone should still have the energy to keep the Summit party ...

12 views 0 0
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you