From the course: Working with LinkedIn Learning Exercise Files on GitHub

Checkout and switch branches - GitHub Tutorial

From the course: Working with LinkedIn Learning Exercise Files on GitHub

Checkout and switch branches

- [Instructor] For the rest of this chapter, I will work in Visual Studio 2019. The actions I'm performing here are similar to what you do in the older versions, they just might be in different places in the IDE. Now, what we're trying to do in this video is look at how to check out and switch branches. To do that, there's two places I can look for in Visual Studio. I can go to the Git menu and choose Manage Branches, or I can go to the bottom of the IDE and I've got information about the repository I'm working with. So this is the name of the repository, here's information about what's changed and over here, is to current branch. And I can see when I click on this up arrow that I can get to View History, Manage Branches and some other things. So let's choose Manage Branches here. So these both take me to the same user interface. I'll show you that again, go here to Git, Manage Branches. So next, what we see is that we are currently in this repository and I'm on the master branch and when I select the master branch, I can see the local history of what's happened, the changes that have happened in this repository. Now there are more branches in this but I haven't checked them out locally. So the ones I haven't checked out locally are shown here in remote origin and here's all the other branches. So I will go and check out 04-02 and 04-11. This is what I used in one of the earlier chapters. So I want to check out this branch, so, I can right click on it and choose Checkout. Now, keep your eye down here in the lower right where it says, Master, checkout 04-02 and several things happen. On the bottom, it shows I'm on this new branch or existing branch, it's the branch that was in the repository. And then up here at the top, it shows me in bold that I searched that branch. So now I've got master available as a local checkout and I've got 04-02 and then you can see, as I switched back and forth, I can see the history and then I can checkout master by right clicking here and checking it out. Or if you prefer, you're probably not going to have the sunscreen because you have your code and other things you're looking at. So you close this window and to switch to the other branch, you go to the bottom right, click on this up arrow and choose this item here. So these are the two items that I have locally and now I've switched over to the 04-02 branch. Now, of course I can check out other branches. At this time, let's check out the branches down here. Go to Manage Branches, go to Remotes, find 04-11, right click, checkout. And you say, I am now on that branching, see that down here in the lower right and now I've got three choices to check out on the local repository. Now let's view the changes in the file. So I'll go to Solution Explorer, I'll go to DebugConsole, open up this Robot.cs file. And then, I am going to scroll down here to this section where they have this four loop and I am going to switch branches, go back to 04-02, and you see the code changes. So again, this is one of the advantages of using it for training as you go through the course, we can have each specific branch have only the code that you need for that lesson.

Contents