UlfL
UlfL

Reputation: 79

How can one in Visual Studio open another GIT-branch without need to commit changes to the current one?

How do one use multiple branches or switch branch without commit?

I'm using GIT with VisualStudio and are working in one branch when a colleague of mine ask me to to something in another. I do not want to commit changes in my first branch. How do I use two branches simultaneously or how do I switch branches without committing pending changes?

Upvotes: 5

Views: 3510

Answers (1)

maxiangelo
maxiangelo

Reputation: 155

When you have uncommitted changes in a branch and you want to switch to another branch you can use git stash to temporarily "save" the changes without committing them.

When you switch back to the branch you can use git stash pop to reapply your changes to the branch.

You can also do more advanced stuff with stash, see the Git Pro book Chapter about it for more.

If you are using Visual Studio 2019 you can stash directly in the Team Explorer, for the 2017 version you can use this extension if you don't want to use the terminal.

Upvotes: 4

Related Questions