Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching branches does not refresh Solution Explorer in Visual Studio

I am probably missing something basic here, but I'm playing around with the Git version of TFS.

I am using Visual Studio 2015 preview (maybe that is my problem), so from a solution I created a master and I made a branch from this master; I'll call it version2.

I made changes to version 2, but I did not commit merge sync or anything. So after messing around with version 2 I went back into Team Explorer, went to the branches tab, and double clicked main (I also tried right click switch).

I was hoping my Solution Explorer would not show the changes I made to version 2, because I had now switched to main. But that is not the case, and I am still seeing all the changes I made in version 2 in Solution Explorer. So how do I get Solution Explorer to reflect the branch I am currently working on?

like image 693
Bryan Dellinger Avatar asked Feb 20 '15 15:02

Bryan Dellinger


People also ask

How do I switch between branches in Visual Studio?

Access the "Source Control" tab on the left side of VSCode. Click on the "three small dots" next to the refresh button. Click on the "Checkout to..." option. Choose the branch you want to switch to.

How do I move the Solution Explorer in Visual Studio?

Click on the title bar, and drag it to the right portion of the screen. Eventually you'll see a compas like structure popup. Make sure you hover over the right area and let go of the mouse button. That will bind it to the right side.

How do I configure Solution Explorer in Visual Studio?

By default, the Solution Explorer tool window appears as a pane in the upper-right side of the Visual Studio integrated development environment (IDE). If you don't see the Solution Explorer tool window, you can open it from the Visual Studio menu bar by using View > Solution Explorer, or by pressing Ctrl+Alt+L.


2 Answers

Git's model is fundamentally different than TFVC. You need to commit the file to your branch (you don't necessarily need to push the change or the branch to the remote server). Once you commit the change, switching branches will behave in the fashion you're expecting.

Git is based on the model of committing changes to local branches frequently. Even if the code doesn't yet compile, it's fine to commit it to a local branch... you can always rebase or cherry-pick later on.

like image 145
Daniel Mann Avatar answered Sep 25 '22 05:09

Daniel Mann


By default in Git if you have pending changes that you have not committed and you switch branch the changes are moved to the new branch. Git is assuming that this is what you want.

If you want to leave the changes on v2 you need to commit the changes with that branch checkout. You can then switch to the v1 branch and see the solution change.

like image 41
MrHinsh - Martin Hinshelwood Avatar answered Sep 22 '22 05:09

MrHinsh - Martin Hinshelwood