
But if the other branch doesn’t point to the same commit, you have to commit your local changes first to checkout the other branch. This works without a problem if the other branch points to the same commit as the branch that you’ve checked out. So, stashing is great for storing changes that you do not want to commit yet.Īnother thing where stashing is quite useful is when you want to switch to another branch.
So let’s select in my case “Pop All as Unstaged”, and then we’re back at the state that we had at the beginning of this blog post.
If you hadn’t any staged files before you created the stash, then you won’t see a difference between the two options.
Pop/Apply All as Unstaged – this will pop/apply the changes to your branch and it won’t stage the files that you had staged before. Pop/Apply and Restore Staged – this will pop/apply the changes to your branch and it will also ensure that files that you had staged before are staged again. You can see them in the screenshot above for the Pop menu: Under the menu items Apply and Pop you find two options. Pop – this will Apply the changes and Drop the stash. Apply – this will apply the changes to the branch and it will keep the stash. Instead of using the context menu to view the changes, you can also double-click the stash.Īs you can see in the picture above, beside the “View Changes” menu the context menu of the stash has also the following options: From the context menu that you get then (you can see it below) you can view the changes. Later you can come back to your feature branch, and there you can right-click on that stash in the Changes page of Team Explorer. Now you can switch for example to another branch. Let’s select “Stash All”.Īfter clicking on “Stash all”, you can see now the created stash, and the branch doesn’t have any changes anymore. So both stash options will have the same effect. But in my case above, I haven’t staged the Program.cs file. If you want to keep the changes in the branch that you have already staged for a commit, you select “Stash All and Keep Staged”. Clicking on “Stash All” will also undo all those uncommitted changes in your branch. So, a stash is like a local copy of your uncommitted changes. This will create a stash that contains all the uncommitted changes. Now click on the Stash button:įrom the drop down, click on “Stash All”. The message is optional for a stash, I entered in the screenshot below the message “First draft of customer login”. Just enter a message in the Changes window of Team Explorer. But you want to save the functionality for now and look at the original branch without changes. But you’re not ready to commit it, as you didn’t reach yet the code quality you normally write. If you have looked already at the Changes page of Team Explorer in Visual Studio 2019, you might have seen that it has a new Stashes section.