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] Let's review our situation. I've cloned the repository to the local folder, and I would like to switch to another branch. First of all, let's take a look at which branch I am currently got checked out on my local computer. So I'll type in git branch, and this tells me that I've only checked out one branch so far, and I'm currently on that branch called master, that's in green text here. Now I can see all their branches are available to me by typing in git branch -a, and all the ones that are in red are in the repository, but I haven't checked out any of those yet so they're not listed as local. So I would like to switch to branch 01-01. So let me clear the screen, first, and then I'll type in git checkout, and then I need to tilt the name of the branch, 01-01. It tells me a switch to a new branch, and it's also telling me it's set up to track the remote branch from 01-01, from origin. And now if I do git branch, again, like this, it shows that I have two branches I've checked out. I am currently on 01-01, that's what the asterisk means, that's where the head is pointing. The green tech shows me that I am on that branch, and then it shows that I also have the master branch available to switch back to master. How would you do that? Git checkout master, and then we'll do a branch to see that we're back on master. So what does this imply for the files? Remember that if I do a dir, here, I'm in the source folder, I only have these two files. Now let's see what happens when I switch to checkout 01-01 and then do a dir. Now you see that I have some sub-folders, DebugConsole, DebugWpf and RobotNameGenerator, and if I drill down, like this, you can see I've got some CS project files in there, those are just C# projects, and I've got a CS file, which is some code file, and I've got a couple of text files. So you see, when you switch branches, it changes the state, now I have a different set of files. So let's go to another branch. So we'll do a git branch -a to see em all. Let's go to chapter four, number two. Oops, I forgot the word check, I forgot the word git, checkout 04-04. I typed in the wrong branch, so you see I got this error, pathspec does not match any files known to git, so that's because I made a typo. I was trying to go to 04-02. Now if I take a look, you see, it looks like the same files, the same folders and same files, but if we were to drill down deeper and take a look at the contents of those files and those projects you'd see they're changing as I'm going through the course.

Contents