简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM