Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On sourcetree, how can I recover stashes after checkout on a different branch?

I had some stashed changes while I was working on a branch.

I wanted to work locally on a different branch so I did checkout into a new branch and lost all the stashes from sourcetree sidebar.

Here is a screenshot of sourcetree:

sourcetree

If I type git stash list on my terminal I get a list of the stashes...

stash@{0}: On feature/SITE-5-doctor-name-at-checkin-success: Before commits
stash@{1}: WIP on feature/SITE-5-doctor-name-at-checkin-success: df48232 WIP show dummyDoctor on success page
stash@{2}: WIP on feature/SITE-5-doctor-name-at-checkin-success: 82b1aed Linting
stash@{3}: On feature/SITE-5-doctor-name-at-checkin-success: DEBUG

...so I know they are not lost.

How do I get them back to my sourcetree sidebar so I can use them in any of those branches?

like image 436
Pedro Nobre de Figueiredo Avatar asked Nov 09 '16 00:11

Pedro Nobre de Figueiredo


People also ask

How do I restore stashed work to new branch?

To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.

Can I apply stash on different branch Sourcetree?

Stashing Your Work Having a clean working directory and applying it on the same branch aren't necessary to successfully apply a stash. You can save a stash on one branch, switch to another branch later, and try to reapply the changes.


1 Answers

Welcome to Stack Overflow :)

Stashes are indeed listed in the sidebar, but in your image they're collapsed. The 'Show' links next to Tags, Remotes, Stashes, etc only show on hover.

Note that trying to apply a stash from one branch to another branch may result in conflicts to resolve. In this case, sourcetree will not delete your stash automatically, as it would usually, rather you'll need to right click and 'delete' stashes once you've successfully applied them.

like image 154
ptim Avatar answered Sep 28 '22 00:09

ptim