dcsimg
November 19, 2019
Hot Topics:

Visual Studio 2019 Git Stash

  • September 25, 2019
  • By Hannes DuPreez
  • Send Email »
  • More Articles »

Visual Studio 2019 has numerous new features, and I have mentioned quite a few already. Today is no exception. Today, I will speak about the new Stashes section of the Team Explorer in Visual Studio 2019.

Team Explorer

As you may or may not know, the Team Explorer in Visual Studio provides source code management. This means that multiple developers can be working on the same project, at the same time—even on the same file. It compares each change and then combines the changes (or merge) into the current project.

After a day's work, or a very important change, you normally would check in your code changes for the merge to take place and the project to be updated and built and distributed along with your changes.

But, what if you are not 100% ready to commit the code as a final submission? What if you need to compare the original version of code (or branch of code) without changes, with the new code? What if you're simply not happy with your code quality?

This where the nice little feature Git Stash comes in.

  1. In the Team Explorer, after you have made your changes, enter the details into the message window of the Changes window of the Team Explorer.
  2. Then, click the Stash button.
  3. From the drop-down, select Stash All.
  4. After clicking Stash All, the created Stash will be shown, and the code branch will not have changes any more.
  5. To navigate back to a stash, simply select the Changes page of the Team Explorer.
  6. Right-click the Stash. A shortcut menu will be shown.
  7. The items are as follows:
    • View Changes: Allows you to view the changes of the Stash.
    • Apply: Applies the changes to the code branch and keeps the Stash.
    • Apply and Restore Staged: Applies changes to code branch and ensures staging of previously staged files again.
    • Apply All as Unstaged: Applies changes to code branch and won't stage files that were staged before.
    • Drop: Deletes the Stash.
    • Pop: Applies the changes to the code branch and deletes the Stash.
    • Pop and Restore Staged: Pops changes to code branch and ensures staging of previously staged files again.
    • Pop All as Unstaged: Pops changes to code branch and won't stage files that were staged before.

Conclusion

Being able to stash changes that you do not want to publish yet is a very nice feature in Visual Studio. It just ensures that you can double check your code and ensure that it is up to standard before going live.







Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.


Thanks for your registration, follow us on our social networks to keep up-to-date