简体   繁体   中英

Not understanding working with Git branches (integrated from Azure DevOps) in Visual Studio 2019

Relatively new to working with Azure Devops, and Git within Visual Studio 2019, with respect to multiple branches (also never worked with Git at all in ANY context, so have been learning Git in general and I thought I was making fairly good progress at that). But, getting pretty frustrated with the behavior I outline here - I must not understand how to make happen what it seems like should happen.

Here's the scenario (should be fairly basic - emphasis on should be): in Azure Devops, I have an organization. Under that organization is a project with a repository. In that repository there is a master branch of a Visual Studio 2019 Solution with its .sln and .csproj and code files etc.

I go into Visual Studio 2019 and connect to Azure Devops, and clone that repository. I start up the solution in VS 2019. So far so good.

Now I have to make a bug fix. So in Visual Studio, I do a create-a-new-branch operation to create a branch named, let's say, "MyBugFix". I look down at the bottom right of the Visual Studio window and I make sure that I have selected the MyBugFix branch to be working in, instead of the master branch. So far so good.

I make some code changes to a few .cs files. I'm good all the way up to this point. In previous work so far, to correct another bug, at this point I did the sync to get the bug fix up into that bug fix branch up into the Azure Devops branch, then merged those code changes into the master branch. All good.

But what has me stumped at this point, in this latest exercise, is distinguishing between the master branch and a new separate branch created from the master branch, with respect to code changes.

Go back 2 paragraphs, where I have selected the MyBugFix branch to work in. As I said, at the lower right of the VS2019 window (right to the left of the little notification bell icon), it says (I think) that I am working in the MyBugFix branch. And I have made code changes to a few .cs files.

But now, at this point, I need to access, if you will, the master branch in order to do a build of the master branch codebase and send the dll to someone, say a new customer who has bought the app.

So it seemed to me, in order to accomplish that, that I could just go down to the lower right corner of the VS2019 window and select "master", so that now it says "master" there, to the left of the notification bell icon instead of "MyBugFix".

So I do that, and my expectation would be that then, when I look at the code in the solution explorer, specifically the .cs files that I had made code changes to, I shouldn't see those code changes in those .cs files. Right?

Only I DO see the modified .cs files. Those .cs files still show as checked out with changes and I see the modified code in them, the mods that I had made previously when I had the "MyBugFix" branch selected at the lower right of the VS2019 window. Even though I thought I had "switched" back to the master branch.

I hope I'm explaining this well enough for y'all to understand what is happening and what it is that I'm missing and not seeing about how to deal with multiple git branches within VS2019. If not, please let me know if I need to expound more on the scenario. The 30,000 foot summary is that all I'm trying to do is switch from working with a non-master branch back to the master branch and do a build of the master branch. Without the code mods that I was making to the non-master branch. Hope that makes sense.

I will attach a screenshot of the lower right corner of VS2019 that I have been referring to. TIA :)

在此处输入图片说明

When you switch branches, any uncommitted changes will go with you. So even though you're on the master branch, you're still going to see those uncommitted changes that you had started on the MyBugFix branch.

So you either need commit those changes , undo those changes , or stash them.

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