Switching branches does not refresh Solution Explorer in Visual Studio

18,270

Solution 1

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.

Solution 2

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.

Share:
18,270
Bryan Dellinger
Author by

Bryan Dellinger

I'm a widowed architect with three sons Greg, Peter, and Bobby, I've recently remarried Carol Martin, a lovely lady, who is also bringing up three very lovely girls. All of them including the mother, have hair of gold, the youngest, Cindy has curls.

Updated on June 02, 2022

Comments

  • Bryan Dellinger
    Bryan Dellinger almost 2 years

    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?