 Hi, welcome to Visual Studio Toolbox. I'm your host, Robert Green, and joining me today is Jeremy Foster. Hello, I'm Jeremy. Hey, Jeremy. Thanks for coming on the show. Yeah, thanks for having me. You probably recognize Jeremy. He is a prolific publisher of videos and code chat, which is a bit of a hiatus, but it's, it'll come back, yes? Yeah, it's struggling right now. I'm real busy, so you know how that goes. I know. I took most of the summer off, and then came back on, it's like people are, where have you been? And then some people said, oh, thank God you're not on anymore. I noticed that you had done a course on MBA, Microsoft Virtual Academy, on Git in Visual Studio. Yeah, and specifically on GitHub. GitHub, and that is a topic that, I did a show about a year ago with Paul Littenden on an overview of Git, but it's kind of an important topic. It's, Git is the place where people put code, it is the place where people do source control, and it's not the most intuitive thing ever invented, perhaps. Not at all. It's extremely powerful, it's great. But I thought maybe you could do some highlights from the show, focus on the Visual Studio stuff, or for the full story, people should go watch the course, we'll have a link to that. But can you show us how to use Git and GitHub inside of Visual Studio and Visual Studio code, and kind of demystify it a little bit? Yeah, yeah, absolutely. This is the course, you can find it, I made a short link for you, codefoster.com slash githubmba. So, if you want six hours of training on GitHub, specifically for Windows users, go here, and you can see that, we talk about the basic concepts, but then we talk about GitHub, and we do the whole workflow in the browser so you can get a feel for what it is that GitHub offers you, just kind of natively, out of the box, not with any tooling or operating system specific stuff. And then we talk about some client tooling, GitHub desktop is like, if you're a Windows user and you like your applications, and you wanna use Git, then you can use GitHub desktop, and it's a very capable client, it's a beautiful client. But then you can also use integrations in Visual Studio, and that's what we'll talk about today. Or you can do the command line. Awesome. You know, for the longest time doing this show, I had wanted somebody to call me, just because I thought it would be funny. But I wasn't gonna stage it, and it actually, a few months ago, it happened, I thought it was hilarious. Now it's even funnier that it happened to a guest. It was just a second, I need to take this. And you can also use the command line, but if I'm writing Visual Studio code, then I probably am gonna wanna do it from inside Visual Studio, or Visual Studio code, of course. That's the thing, for a lot of classic Windows developers. And I assume eventually we'll add it to Xamarin Studio. Yeah. I assume. I'm sure. Yeah. It needs to be everywhere. Right. The thing is for a lot of Windows, for a lot of Microsoft developers, they're used to a graphical user interface. Their IDE is heavily influenced by a graphical user interface, and then they're designing apps that are GUIs. And so it's not natural for a lot of Microsoft developers to drop down to the command line and do things. And that's kind of changing a bit. Or to have the context, which where you leave Visual Studio, go to the website or a different client tool, do something that you would think to yourself, well, why don't I just do this inside Visual Studio? Because it's just calling an API. Yeah. Right, it's not like it's... And for all the real common workflows in source control using Git, it's all there in Visual Studio. And I know people that have no desire to go to the command line at all, and yet they use Git extensively in Visual Studio because all the basic things are there. Right. Cool. Yeah. So and really what we have, what I want to talk about is like diving into the Visual Studio specific topic. There's two Visual Studios now, really. There's Visual Studio 2015, all the various editions of that. And then there's Visual Studio Code. Right. And you said that on Toolbox, you talk about both of those. Yep, absolutely. Yeah, and there's Git functionality in both of those. So we'll look at both. Cool. All right. The first one is Visual Studio. I call it Visual Studio Proper, like I supposed to code Visual Studio Proper. And in Visual Studio, like say 2015 Community Edition, there's all the editions, really. There's an extension called the GitHub extension for Visual Studio. Okay. Now that is the one plug-in that you should use because if you go to the extensions search and search online for Git or GitHub, you're going to find a bunch of stuff. Right. But the flagship one, the one that you really want is the GitHub extension. And what you'll notice over time is that it updates on a fairly regular basis. So you're constantly reminded that you have it. Yeah, there you go. And it's like, oh, there's a new version. It's okay, I'll get it. I've never used it, but I want to stay current. Absolutely. And just so you know, there was an older one called Visual Studio Tools Forget. Okay. That was Visual Studio 2012 and earlier. And you probably won't be using that one anymore. It's not as robust, not as capable. Right. Okay. Yeah, so let's go ahead and jump into a demo on the GitHub extension. So I'm going to jump over to Visual Studio. And it's the Visual Studio we all know and love. Visual Studio 2015 community is what I'm in. And if I go up to my tools. Does that be showing up on the screen there? It should. Are you projecting? I have it on my screen, I'm being selfish. I'm viewing it on my screen. There it is. Okay. That way I get to see. That's right. So now I'm going to go to tools and extensions and updates. And I did that kind of quick. Let me just go ahead and extensions and updates. Now, probably if you did- You don't see the flag here. Yeah, there you go. I've got an update. I've got something. I think the one I have to update is the Azure tools. And so it's a big one. So I didn't want to do it right before the show. But you'll see in here that you've got the GitHub extension. You've probably already got it because it kind of comes with the stock build. But if you don't, then just search for GitHub in there and you'll get it. So that once you have that, then you have quite a bit of tooling in Visual Studio that's just kind of done for you. It's kind of ready. And most of that is going to be inside the Team Explorer tab. So in Team Explorer, now you can get lost in here, but you can always go back home and you can look at what different providers you have. And I clicked on the little connect thing and you can see that you've got GitHub in here. Right. But let me draw you. It's your VSTS. Yeah, that's right. Yeah, so you can choose and Visual Studio of course you can do either. And I want to draw your attention to the fact that there's a GitHub section in here and there's a local Git repository section in here. So it's confusing, but Git is a technology. And GitHub is a service online. It's a company that uses Git and facilitates you using Git and it's your cloud provider. I think the two terms are kind of used together. People, when you say, oh, you should put that in Git, GitHub, Git. I think people kind of think it's the same thing, but Git is the underlying plumbing, right? And GitHub is a repository, an online repository, if you will. That's right. I'm misusing the term, but an online place where you can put code. Yep, absolutely. Yeah, and really Git is an offline source control. So I have the entire copy of the repository and then if you're working together with me on a project, you do too. And so does Jane and Jill and Joe. But then we all, we all could communicate directly with each other, but it would get difficult. So it's nice to have a common place in the cloud and that's where GitHub becomes, okay? Yeah. So right now I have two of my projects on. This isn't showing me all the stuff I have in my GitHub. I have a lot more repositories in this, but here are two of them that I'm kind of working on now. And when you use these commands, just think, this is in the cloud. So if I clone, I'm cloning from the cloud, that's copying a repository down from the cloud. If I create, I'm creating a repo in the cloud. So repo or repository is a basically, is it a project, is it a solution, is it a folder? Yeah. So when you're coming from the visual studio world, you have to do that mapping. And it's really, it's none of those. Or any of those, whatever you want it to be. A repo is just a collection of files and folders. Okay, so what is a collection? Yep, it is a collection. Now, some people will say, you know what? I've got a solution with four projects in it, that whole thing belongs in one GitHub repo. Other people will say, they might have a GitHub repo that's even one level higher and they have a folder with all of their graphics. That's not in visual studio maybe. You know, it's like all their website graphics and stuff like that. And then they have a folder called code and that's where they have all their code. So you could go a level higher. You could also go a level lower and this is actually very common. There's some good arguments for this. You could have a different GitHub repo for each project in your solution, okay? There's some real reasons to do that because if a GitHub repo represents a single project, then it makes it easy to deploy that project to something like Azure. Okay. Okay, because that repo represents the entire project. Okay. So clone that pulls something down. It might make it easier if you're working on a solution with a whole bunch of projects and you and I are only working on a couple of projects each, then I might not want the entire solution brought down. I may just want to work with the repo which represents the project I happen to be working with. That's true. If you have a gigantic solution, all the more reason to break it out because otherwise anybody that clones your repo is cloning the entire solution. Okay. I've worked on some really big solutions in the past that have 125 projects in them and that you would never want. You could put all of that in GitHub but probably wouldn't want to. Okay. Okay, so the create there creates it on the web. Let's just go ahead and do that. I'm gonna go ahead and hit create right here and it's gonna bring up this little dialog box. Actually, let me jump back and say if you don't see this yet, you see GitHub and you have a little connect button. That means you haven't signed in. Okay. So you click connect and sign in. But now I can just create a repo whatever I want. Let's call it whatever I want. Mm-hmm. And I can give it a description or I don't have to. Now this is telling Visual Studio where I want to put the local version of this. So I'm kind of doing two things. Can you control that path? Absolutely. Yeah, there's a settings in here. Okay. And in the settings you can tell it where your default path is. I don't remember exactly where it's at but it's in here somewhere. Okay. What you want it to be for your default path and you can also set your user information. What's the best practice for that? Well, you know what I do is I put everything under code. Yeah. That way all my paths are really short. It's really easy to get to. Yeah, the problem with putting things under users is if you then need to repave your machine. Yeah. Then you need to remember to have copied that. Except for this, most of the stuff in my code folder is already in the cloud. Oh, it's already up in the cloud as well. That's right. Wipe out that folder at any time and then just, no, it might not be the case. I might have some work in there. So when I pave my machine, I go through my projects and I go, do I have any outstanding work on that or that or that? Right. Yeah. Right. But it's really nice not having it buried in there because a lot of my code, whether it's a Visual Studio project or I work a lot on Node.js projects and in either case, you get these gigantic collections of files, right? All your dependencies and their dependencies. Right. I don't like syncing all that stuff up to OneDrive when it's really all just redundant stuff anyway. Yeah. Okay. Okay, so I'm going to put this under code. Actually, I'm going to put this under Scratch just because we're playing right now and I'll call it whatever I want. Now here it asks me for a git ignore file and a license and those are important to do. I say you do them right away. The git ignore file here, it's defaulting to Visual Studio which makes sense because I'm creating this in Visual Studio. What that means is that it's actually going to seed this repository with a file called .gitignore and that file ignores specifies some things that git should ignore, some common things like the bin folder or the obj folder. Those are derivative folders. Packages? Does it ignore packages? I think by default it does. I'm not positive. That would be a good one to ignore. Depending on what you're using, packages can be 50 to 75 megabytes. Absolutely. Rebuild, it repopulates that when you. We'll take a look at it. Okay. Yeah, those things like that, like your packages folder, your dependencies folder, they're just derivative. You could regenerate them at any time so you don't need to check those into your source control. Yeah. Okay, and then choose a license. I like to go with Apache, so let's choose an Apache license. Now this is going into my account. When I sign up for GitHub, I have a place to put my repositories and it's under my personal account but I can also create or join organizations. Organizations are like places for people to collect and put repos that are shared among them and no one person owns it. If you go somewhere like github.com slash Microsoft, that's an organization. Right. You can create your own and as long as the repos in it are public, it's all free, so that's cool. But I can choose here, whether I want this to go into my personal one or any of the orgs that I'm involved in. You can see all the orgs that I'm involved in. But I'll just put this under my personal and then create. Now since this is creating it in the cloud, I should be able to jump out to github.com and I'll go to my account and I'll go to my repos and look at that. Whatever I want exists. Let's click on it. Should it have anything? It should because we specified that we want it seeded with some files. Forget ignore, let's look at that. And let's see if we can find the packages folder in here. I'm guessing that it is in there. It's pretty big. There's a lot of stuff that, you know that you might find. Look at packages, there it is. Okay, got it. Yeah. Awesome. Ah, nice. That's nice for that to be ignored. If you wanted to include those, you could just edit that file, presumably and have it include the packages. That's right. And then it also gave us a readme file. This readme file is a little bit special because whatever is in it, is what shows up on this page. So if you send somebody to your GitHub repo, like you're creating some sample code and you want to tell people, go here and look at it. Well, when they first get there, you want it to look nice. You want it to look like you're doing something. Exactly. You want it to be created once and abandoned. Yeah, exactly. Exactly, yeah. Now we've got no code in here, so it's sad, want, want, want. But let's jump over to Visual Studio and let's go to the whatever I want that I just created. Now, when I created it up here on GitHub, it also created for me this local repository. Okay, two very different things, but it made both for me. Let's go to the whatever I want, and now we're in a little more specific page inside of Team Explorer. And this section at the bottom is interesting. It says solutions, new or open. This is Visual Studio saying I'm Visual Studio, so I only work with solutions and projects. That's how you open code in Visual Studio. So I'm looking for some. There aren't any. I found three files in there. None of them was a CSPROJ or whatever. So let's say, all right, let's go ahead and create a new one. And it opens the familiar file new project dialog box. So let's create a C-sharp console. And then interestingly, create new Git repository is checked. Yeah, and I actually, I don't know how that will behave. I'm gonna go ahead and uncheck that because Because you already have a repo. I have a repo. I don't want this to be its own repo. Glad you pointed that out. And it is gonna create a folder and it's gonna put it in that whatever I want folder by default. And here we go. Okay, so I've got myself a nice little project. Now that SLN file now shows up here so that if anybody else pulls this project down from the web, opens it in Visual Studio and then double clicks on it, they'll see under solutions, a solution. And so it's easy to open it in Visual Studio. Now, if I go back, I'm sorry, I didn't wanna go back. Let's go back forward. If I go to changes, it should show me that I've got a bunch of stuff that I haven't checked in because I just created a whole project and none of that stuff is checked in. Now, by the way, I'm gonna jump to this in my command line just to show you that everything you do in Visual Studio is 100% in sync with whatever you do with Git anywhere else. So if I'm in Visual Studio, if I'm on my command line here and I go into my scratch folder into whatever I want, I see this whatever I want repo and there's my stuff. All right, now here I'm local so I see my console application that I just created. If I jump out to the web, I don't see that. I haven't put it up there yet. Your local repo is that code just sitting on your hard drive. It's not in the cloud yet. That's right. And as a matter of fact, it's not even in my local repo, it's in my local working directory and I haven't checked it in yet. You see this little two, it's hard to see but there's a little two there saying there's a couple of things in here. There's the Git attributes and this folder that are new. You haven't committed those yet. And so I could commit those on the command line but we wanna see how this works in Visual Studio so let's go there and we'll say, okay, all of this code, it's good. It's simple, it's just a console application that does nothing but it's good. This is like my initial commit. So I'll say initial commit and then I'll say commit all. Now what just happened is I moved those files from just being in my working directory to also being in my local repo. So I committed them. That's what a commit is. It's saying I like my code. It's good, it's done. I'm gonna commit it. Is that a physical thing or a virtual thing? It's a physical thing. It actually- So you have two copies of this code on your disk? Not really. Not really. Well, technically now I do. Technically, well let me show you this. I'm gonna go into, I'm gonna do the PowerShell II which is invoke this folder. So it's gonna open it in Explorer here. Now you see this hidden folder, this git? If I dig into that, which I'm perfectly welcome to do, it's my computer. I go to objects. There are all these hexadecimal codes for all of these objects that exist in my repo. It's nothing you really wanna look at but all your stuff actually exists in here. So you probably don't wanna delete that folder. You don't, you don't. You lose all your history if you delete that folder. Okay. Yeah, voice and experience. So. Or so you've been told. So I've been to, it's not like I've ever deleted stuff. Yeah. So all of this, this is not just the current state of affairs in this project, it's all of history as well. Got it, okay. And git is basically, when you say I want to go to a certain branch, all it's doing is it's making your working directory match what it has in its object. Got it, okay. Okay, so now I have it local. Let's go back to Visual Studio. I have that commit. If I go back and I hit sync, it'll say, okay, there's an outgoing commit. There's this commit you call the initial commit. That's here, but it's not up on the server. So it needs to be pushed up. Now there's a git concept called pull to take code from the server and bring it down. And a git concept called push, which is the opposite. And what's a fetch? Now a fetch brings it down, but doesn't merge it into your current working. Okay. In your current branch. So a fetch, you won't see anything happen. It'll say, okay, I just fetched it. I would say fetch is what you want to do right before you get on the airplane. Because if somebody else worked on your project, if you hit fetch, it pulls it in, so you have access to it, but it doesn't mess with where you were at. If you try to do a pull right before you get on the airplane and you were working on stuff, it's gonna be blood all over the place. Got it. Yeah, so pull and push are git concepts, but Visual Studio has this concept of sync. It's really just a pull and a push. Right. But it gives you sync because it makes good sense to have this one operation that does everything. So let's go ahead and- In this case, it knows there's nothing to pull. Yeah. So it's just going to push in this case. Yeah, it's actually gonna try a pull and say, oh, you're already up to date, there's nothing new. So I could now push or sync, it doesn't really matter. I'll sync it, it'll say, okay, I'm trying to pull, nothing new, okay, now I'm trying to push. And then there's nothing in outgoing because you're done. That's right. And if I went back and went to changes, there are no pending changes. So this is what's called a clean working directory. There's nothing to see here, move along. Now if I jump out to the web and hit refresh, now we can see that my code's up there. It's up there. Now let's go into there and look at the, not at the solution, but at the program.cs, which is where I'm gonna write this code. And it's a blank, right? It's blank right now. So let's go make a change in Visual Studio. Here we go, let's do a console write line. Hello world, there it is. Now this is gorgeous. I mean, all the code I just wrote here is perfect. I love it. I've tested it, it checks out. So let's go ahead and push this in. Now, if I look in my team explorer under changes, I see that this file has been changed. And I could actually compare this with the unmodified version to see what my changes are. Which is another reason not to delete that hidden folder. That gif folder. Because this is looking locally to do that. Exactly, it's looking locally, absolutely. Now I have mine configured to use an external tool. You could use Visual Studio as well, but mine's using an external tool and I'll cancel that. Okay, now I'm gonna go ahead and this is just perfect. So I'm gonna say created hello world. And I deserve an exclamation point on that. Now these are the changes and I can choose to stage or unstage. This is a concept that we haven't talked about yet. You know that we have a working directory that's our files and folders. And before you commit them, you stage them because it may be that you just made three changes or changes to three files, but only one of them really pertains to the present commit. You want to commit just one of those. Okay, so I go, yeah, let's go ahead and stage that one. It says, well, first you gotta save it. That makes good sense. I'm used to Visual Studio code where it just saves automatically. So, okay, now that's a staged change. Which means that if I do a commit, that's what's gonna get committed. Does that make sense? Okay, so the staged changes get committed. That's right, got it. Anything down here doesn't get committed. As a matter of fact, let's go ahead and create another file in the solution explorer. Let's do a add a new item and I just want a text file. Text file, there it is, text file one. Now let's go to the changes. And look at this. I've got text file one and by adding a file, I changed my project. But neither of those do I want to commit right now because this was just the creation of Hello World. So I stage that change. I add my commit message and I go ahead and commit it. Can you promote one change at a time? Or do you have to do everything in there? Everything in that file? You can. Or everything because the plus is at the changes level. Can you just promote that? You can, yeah, whenever you right click on one of these, you can stage just that one. Cool. Or you can promote everything. Yep. And what I thought you were asking is also kind of interesting. If inside of this one file, I had a hundred lines of code, a little block at the top that I changed and a little block at the bottom that I changed. And maybe that those are completely unrelated changes, right? And so I could just commit part of that file. Oh really? And what it actually does is internally it kind of splits that file, stages the part, just the one change and then I can commit that separately. And that's a good idea because if you are looking through your team's history and somebody said I made a bunch of changes, that doesn't help you. It's hard to read that. And so if it says I did this and then I did this and then I did this, those make a lot more sense. Yes. Okay, so I staged one file and committed it. Now let's go ahead and stage the rest and make a separate commit. So I'm gonna stage that. It asks me to do some save. That makes good sense. They're both staged. And for this one, I added a text file. Commit that. Okay, now locally I have two commits. I've not touched the server. Locally I have two commits. And to see those, I go back and I go to sync and it'll say outgoing there are these two commits. Yep. Okay, and this is why it makes really good sense to have very atomic commits. Only the only changes, all the changes in a commit should pertain to the same atomic change in code, okay? So if you're just going crazy every once in a while, you know, like do one thing, like add some console logs and then go check that in and then enable your key and check that in. In reality, do people do that or do they just check everything in at the end of the day? Good citizens do, yeah. No, people don't. Let's not be, let's not be judgmental. In the real world, is that the way most people do it or do most people just? I think most people do atomic commits. That's part of the culture of Git. It could be better. Sometimes people have a few changes from one file but people definitely don't just check all their code in at the end of the day. That doesn't happen. Okay, so two staged or two commits out going ready to go. I go ahead and do a sync and it's gonna pull, nothing to pull, it's gonna push and now those changes are out there on the web. So you don't have to sync them separately. Right, okay. When you sync it up, it pushes all of those commits up. Now when I go to this repo to my code, I see that I have four commits and if I look at my commit history, there they all are. I was just about to ask you where's the history, there it is. Now I'm currently on this branch but every single point in time is recorded in Git as a commit, as a certain commit and that commit has a certain hash. And so I can jump back to the state of this application at any of these points in time. Right, okay. Now when you do that, you're kind of drifting. You're not on a branch, you couldn't make changes and check them in and expect it to play well with the rest of the team. In fact, I think it might even give you, it gives you a message on the console that you're in a disconnected state. So that's not a rollback. That's not a rollback, I didn't just affect things. No, anybody else that comes here, they'll go to master and they'll see the current version, not that old version. Yep, okay. Okay, so that's Visual Studio 2015's with GitHub extension for Visual Studio. So two questions. Sure. What's the difference between clone and download? When would I do which? All right, so let's put them in order. There's download, just give me the code. There's clone, which is pull the code and then there's fork it and clone it. And those three different things you would use for three very different use cases. I would download if I just want the code. I'm never gonna change it. I don't care about any future revisions to it. Nothing, I just want the code. And so you can download it. It's actually easier. So if I'm putting a sample up there, I'm giving a conference talk and I put my samples up there. People can clone, but they can't push back unless I explicitly tell them they can't. That's right, when they try to push their console or Visual Studio or whoever asks them to sign in, and if they don't have rights to that repository and GitHub won't let them. So now, second question. Go into Visual Studio, create the console app and then add it to Git. How do we do that? So if it already exists. It already exists. Okay, let's go there. Oh, and actually let me finish the thought on that. There were the three things. There's download, clone, and then fork and clone. If I just want the code and I don't care about any future revisions, I just download it. It's a zip file, everybody knows how to do that. Helped in the name of my restaurant, if I open a restaurant, fork and clone. Fork and clone, that's a good idea. Great idea. Now I clone it, and actually it's more common to clone than download because cloning is just as easy if not easier. And when you clone it, you get the code, but it also has a pointer back to where it came from. And so you can do a get pull at any point and it'll go get the latest version. So that'd be the easiest if someone's gonna keep making changes to that. Yeah, like you have the sample code and you tell somebody about it. If they just download it, they have a static unchanging copy of it. That was the code as of the day you pulled it or as of the last time I put it up there. Yeah, okay. That's right, but if they clone it, then they could at any point in time say get pull and it'll be like all your new changes are coming down to their computer. Now the third version is if you're in an open source workflow where they're not a part of your repository, they're just somebody on the web. They would fork your project which makes a copy in their GitHub account and then they would clone theirs and then they would make their changes and they could request that those changes be pulled into the main project. That's the common open source workflow. Got it, okay. But that's probably for another video. Okay, so you wanted to say I've already got a solution and I wanna do that. Okay, so let's go ahead and file closed solution. I'm going to create a new project. Let's stick with the open source, or I'm sorry, stick with the console application and I'll go into Scratch and I'll just put it in here. This is console application two. And I'm not gonna choose to put this, that's another way but we won't talk about that right now. This is code that already exists. Somebody's watching this show going, oh, I wanna get on that train. Yes, right. But I have an existing project. Yep, that's a really good idea to go through that. Okay, it's pausing for me here. And while it does, let's jump down to the command line. So I've got console application two here. There's nothing in it. Well, there is so far. There's a project file folder. All right, so I've got that created. Let's say this is console application two. I've just to have a little bit of code there. But this is not a Git repository as evidenced by the fact that if I open this in Windows Explorer, it says, well, I've got this hidden VS folder but I don't have a hidden.git folder. So I know that that is not a Git repository. Now creating it as a Git repository from the command line, watch this. Git init. Okay, now it is. And if I jump over here, I can see that it created that folder. I created it locally. Created it. It turned this local file, this local folder into a Git repository. Now to turn that off, it's as simple as deleting that folder. Okay, so turning something into a Git repo is just doing a Git init and turning it off is basically just deleting that file. Okay, but let's say we wanna do that from inside of Visual Studio. Now this only exists locally. So let's go to my connecting page here and it'll show all my local Git repositories. Now, there is an option in here. You mentioned, can you change the settings? And it would be really cool if I could find that. Here it is. Drop that down and choose settings. And in here, I get to change my global Git settings, my name, email address. And I'm just gonna say, you know what? I normally put my stuff under code. And there's a couple of other options. This is actually a really good one to choose. Enable the download of author images from third party. That way when you're collaborating with people, you get to see their avatar in there. So I'll go ahead and update that. And this is where I've got my diff and merge tools configured to use beyond compare. That's for another day as well. Okay, so let's jump back here. And now, right now I don't see that as a local repo just because I haven't brought it in here. If it scanned your whole hard drive and brought in every Git repo, it'd probably be too busy. So it waits for you to add them. Not create a new one, but to add an existing one. So I'm going to add, it's looking in code, but I'm gonna say no, I'm actually interested in, oh, and you know what? I think I've got backwards on this because if I go console application two, if I look inside there, that's not gonna be a Git repo yet. So I think I do want to create a new one. New, and let's go ahead and browse for it. Let's browse for scratch console app two, console app two. Okay, create that. Now it already exists and it's not empty. Okay, so I'm confused here. Let me try, let me try it might be add. I don't normally do this. Let me, we'll go into scratch again. Console app two, console app two, okay, add. All right, so that was the workflow. Ignore my first thing. So if you have a folder that already exists, it's already a project, then you want to create a new GitHub repo out of an existing folder. You do that and now it should be here, right? Expect it to be in here. Let's go look in here and it did not actually do it. So Robert, I'm all confused. I'm all washed up. Let's try it one more time. Let's say new and we'll browse. We'll go to see, scratch, console app two, add folder, yes, and create. Already exists and it's not empty. Oh, I didn't see that. Okay, so it won't let you do that. That's really interesting. There's probably a way to do it and I just don't know it. What this is asking you to do is to create, like we've already got console app two. If I wanted to create a repository foo, it's going to do that for me. Now I've got foo and that's where it exists. If I wanted to add an existing repository, like let's say I didn't have foo in here, I can remove that. If I don't have foo in there, then I can browse to foo, which is already a get repo, and I can add it and that works. But what I can't do is take a folder that I already have that exists as a get repo and reference it in. That's not yet a get repo and turn it into a get repo. So then what you need to do is create the empty folder with the repo and copy the files over? Which would probably be a good idea anyway. To go to that folder's parent and create a get repo there and then drag that folder into it. Right. Or could you then take the project and add it to source control and specify get and that will do that for you? Let's give that a try. So let's take this folder that we already have and right click on the solution. Add it to source control. Add it to source control and let's see if this works. Wants me to save it, good idea. It's all saved and I don't see that that did anything. It did do it. Look at that. Okay. And it may have done that earlier on your machine but it didn't recognize it. Okay, so that's the easiest way to do it. There you go. If it's not already under source control add it, creates the local get repository and now you can sync. Well this. Wait, oh wait, you still gotta create it there or will it create it for you? You're exactly right. It's not in GitHub yet. So I think that I'll still be able to go to sync for that. I'm not sync, I wanna go to that one. Okay, there we go. Now notice that there are fewer options here because it doesn't exist yet in GitHub. Okay. Sync in this case is gonna publish it. That's gonna put it into GitHub. All right. And publish to GitHub. Oh, there we go. There it is. Publish the get repo. Enter the URL of an empty get repo. That isn't creating it for you. Okay, so you're still gonna go to the website or the command line, create the repo and then you can publish to it. Yeah, and you can create the repo here. Remember that up here you can create a repo. Yeah, so you can say let's create console application too. It's just not gonna prompt you for that. So let's do that. Visual Studio, pick a license, go for it. Now that exists. And so now if I double click on console application too and hit sync, it takes me here and I publish it and it says what is the URL? The URLs are easy. At first you're like I've gotta go copy it but it's actually just github.com, got a spell right, code foster and that one was called console application too. Publish it. Invalid URL. It's just not our day. Oh, look, I had one slash. Somebody on camera should have caught that and I don't know, tweeted it. Ooh, I've already got one. You already got one. Okay, at any rate, this is how you do it. Okay, all right. Yeah, probably I wouldn't suggest just taking your existing project and trying to do it just like that. You might wanna start over with a repo and move your folder into it. Get it situated the way you want, structured the way you want and then go ahead and add those changes and check them in. Okay, cool. Now, Visual Studio Code is the other way you can do it. You know, Visual Studio Code you tend to use when you're working on kind of different types of projects. Or when you just wanna see the contents of a .cs file. Yeah, that's right. That's what I do. It's not my default editor. Yeah, I used to use Notepad for that and now I just use VS Code. That's right. Now, if I go to, let's go back up to my scratch folder. There's also my surreptitious way of always making sure VS Code's updated because if I look at a .cs file, VS Code launches and then it tells me there's a new update. I go, all right, update. You wanna make sure you stay current even if you're not using it. Let's go ahead and create a, I don't think I have a foo too, so let's make directory foo too. And we're gonna do this, it does already exist. Let's make directory foo 20. I bet that doesn't exist. We're gonna do this a little bit backwards. When you're using code, Visual Studio Code, you do tend to use the command line more. Yes. It doesn't try to replace all the command line, it tries to compliment the command line and people that use code or other applications like code tend to be the more of the command line type people. The folks that like the lightweight editor, not the big, fat IDEs like me. So let's say I'm gonna- I'm a big, fat IDE guy. Fat IDE guy? I'm just gonna say it right up front. It's a good IDE. Big, fat IDEs with wizards and all the help I can get. About a thousand buttons on the screen in any given time. Yeah, absolutely. That's right. Okay, so let's follow kind of a traditional workflow for creating something if you're doing in code. Let's say I'm gonna make a node app. I'm gonna make a folder, which I just did foo 20 and then go into it. And do you remember how I initialized that as a get repository? Do I? Get a net. Get a net. And all that did was create a .get. Right. Now, if I want to open this folder, actually, first let's say I wanted to create an HTML file. I could do touch index.html and that will create that file. Touch is a PowerShell command? It's actually a Linux command. It's a Linux command. I think there's actually an alias for it in PowerShell if I'm not mistaken. But I create a path to my get bin folder, which gives me a whole bunch of the popular Linux commands. So then when somebody from the Linux world says, try this and you type it, it actually works. You've actually got that command. So I create a file and now I'm going to open that in code by simply typing code this folder. And code doesn't look for a project file or a solution file, it just looks for a folder. And there's my index.html. Now let's go ahead and say I want some HTML here. So I'm gonna use, have you seen the emit auto complete? No. For HTML, this exists in Visual Studio as well as Visual Studio Code. You can type any HTML for the most part, like I want a div. So you just type div tab and you've got your div open and close. You can also say I want a div that contains an unordered list that contains five li's. And I want those to all have some lorem ipsum text. And it creates all that. Nice. It's extremely handy. And so whenever I'm creating an HTML file, HTML colon five is a good way to get the basic HTML template. So let's say in here, let's just have a line that's just A. Okay, we'll just say A and put a break after. That's it. Now let's go ahead and check this in. Same thing we just did in Visual Studio 2015, but now in code. Where's the Team Explorer? Yeah, where is Team Explorer? Well, it's not in here. You don't get that with code. In code, get functionality is built right in. It's just expecting that. And you come over here to the left and you just click on get. And this is where it is. There's your changes. If it tells you you have one change, right? And so I can say, okay, let's go ahead and stage that change. And then let's write a get message here. That's just A, because that's all I added was an A. And then I hit go and it commits that. And now, if I look down here on the bottom, see it says I'm on the master branch. Now this doesn't exist in GitHub yet. I haven't created this in GitHub. This is just local. I could go ahead and make more changes, commit them, and I have all these changes local. It is a Git repo, but it's not a Git repo in the cloud at all. And if I look down here, I see master, but there's normally an icon next to it that represents your connection to the cloud. And it's not there, because I'm not connected to the cloud yet. In Git terms, what that means is that if I say, get remote, show me all my remotes. Actually, yeah, get remote. V says verbose, show me all my remotes. It says you don't have any remotes. In other words, you're not connected to, you're not referencing a certain place in the cloud. Now here, just like in Visual Studio, we went to the GitHub section and said create a new one in GitHub. Here, we would do this on the command line. So what you would do is you would NPM install. You can type it out or you can just do an I. A global tool, so dash G, and it's called GH. So there's a tool out there in the community in the NPM repository called GitHub, GH. And that is a really good command line tool for accessing GitHub. So it's different from Git. So you do that outside of code. Outside of code, I'm on the command line. Outside of code, absolutely. And it doesn't matter if you use code or notepad or notepad plus plus. But you can do that from inside code? Inside code, you can open your command line but you're still doing it on the command line. Okay, all right. So I'm installing GH. I already have that, so I'm going to back that out. And I'm going to say GitHub repo. And then tell me what I can do with the repo command. And the GH command is going to say, well, here's all the cool things you can do with GitHub repos. You can scroll up a little bit. You can browse them, clone them, delete them, get details, fork them, list them. You can create a new one. Let's do that. The GH repo dash dash new, and we'll call this foo 20. Because that's what we called it locally. And now that is going to on GitHub. It's using GitHub's API. On GitHub, it's going to create the foo 20 repo. And then it's going to open my browser and show me that, hey, foo 20 repo actually. I wish it didn't open the browser. I don't actually need that. I want to stay on the command line. But that exists now. And now if I say get remote and show me my remotes, it's still not connected. So now I would need to manually tie that up. And so I could say get remote, add one called origin. That's what by default people call their main remote. And I want that to be a point or two. I can go out and copy this. That'll be a little bit faster. I'll go ahead and get the clone URL and paste that in here. And now if I jump over to Visual Studio Code, it's going to say in just a second, I see that I have a connection to the cloud now. Although the branch that you're on called master is not yet published. So notice that icon looks like an arrow going to the cloud. That's the publish arrow. So let's go ahead and publish. Boom. So you're sure you want to publish master to the origin remote. And there we go. It's going up. Uh-oh. There was an error. Anytime Visual Studio Code. Visual Studio Code is really just calling get commands on your behalf. So you can show the output command down here and it'll show you what happened that was bad. Let's look at this. Oh, I was in the wrong one. I was in whatever I want. Let's go to foo20. This is the command that I want. Now you'll get to see the inner workings here. Instead of get remote add, I'm going to do get remote set URL of origin to this. Change that. Now let's try this again. We'll jump back to Visual Studio. Try to run that. And it worked. So now the icon is now a little double arrow thing. Like we're connected to this branch in the cloud and you can just sync it any time you want. So Visual Studio Code feels a bit more native. So you haven't, have you pushed? I did. Whenever I put publish, that actually pushed it to the cloud. Yeah. Publish is one of those Visual Studio terms. It's really just right. I'm pushing it. Yeah. OK, so now if I look in the code for foo20, I see that I have index.html. I can look at it and see that A. Now let's go ahead and go through a simple workflow here. Let's create a B. OK? So I've got A and B. Now I see this little one up here saying you've changed a file. I look at that file and I click on it and it shows me the code comparison right next to it. Now let's do something kind of fun here. On that file, let's also add C and D. But let's say that the change, the changes are unrelated. I really only want to check in this one right here. Right. So I can highlight that line. And in Visual Studio Code, I can say I just want to stage that one line. And check this out. Now over here, I've got a, oops, in my get, I've got a staged change, which is just the C. And I've got a pending change, which is the B and the D. So now I can say C. I added C. Commit that. And now let's go ahead and stage this one B and D. I can stage those ones. Now those are atomic changes. And I can publish all of that by clicking here and saying sync or by clicking down here. Notice that it gives me this little indicator that says you have two ready to go up and none ready to come down. OK, so those are all in the cloud now. So that's kind of the built-in functionality and code. But there's also some extensions. I don't know if you want to see those. OK. So extensions in VS Code are really fun to create. And there's a lot of them. And there are a lot of them that pertain to get. So if you just go into here and search for get, you're going to find a ton. But I wrote down a few of them. They are annotator is one. Get history. I'm not going to show all of these. Share code. I'm going to show you get history, first of all. I rely on that one. And I already have it installed. So if I'm on this file here, let me go ahead and get out of the comparison view and drop down to just the file view. If I'm in this file and I'm wondering, OK, so this is what it looks like now. But what did it used to look like? I can jump up to my command palette and say get history. And first of all, I can show the history overall of my, this basically just shows me all my commits. But I can also say get history. And I just want the history of this one file. And there it shows me all my commits. And for any one of those, I can say for the B and D, I want to compare that against its previous version. Or I can compare it against what I'm looking at. So let's compare it against its previous version. And it says, ah, this was that change. You had it a B and a D. Yeah, very nice. You can do that for anywhere you want in all of history. Now, you were talking about sharing sample code at events. If you want to share an entire project, just create a get repo. But if you just want to share a snippet, you just want to tell people, here's how you make that call. It's just one line. You don't want to create a repo for that. You just want to share that code. In that case, you would create a gist. And that's a GitHub thing. GitHub has gists. And so you could go over to gist.github.com and create it. But there's also a plug-in. So if you're wanting to share this code with somebody, you can go to share code. And I don't have the extension installed right now. Share code. Let's install it. Now, whenever you install an extension, Visual Studio Code makes you reload the window in order for that extension to be recognized. So after the installation, Visual Studio does the same thing. Oh, yeah. Yeah, usually. That's right. Oh, yeah. It makes you restart the program. Yeah, here it just restarts this instance of Visual Studio Code. And so you have to hit Enable. And what that does is restarts it. OK. Now I can highlight this. And almost everything that you install, you find in the command palette. So this gives me share code. So I can share code, share it. And it says, how do you want to share it? You can use Pastebin or you can use GitHub Gist. GitHub Gist Anonymous means it doesn't even require you to sign in. So let's do that for now. And I want it to be public. So enter to confirm your input. This is the description. This is A, B, C, and D. I know. Cool, right? OK. And now it jumps us out to the browser to this anonymous URL that you can give to anybody. And they get to see that little snippet of code. OK. Nice. Yep. There are more extensions, but I don't know if that's the, let me just mention them. Opening GitHub is a quick way to just jump to the GitHub page so that maybe you want to copy the URL or something. PartialDiff, gitignore is a nice one for generating those gitignore files. You can say, I want to start on a Ruby project. I need a gitignore file for that or a Visual Studio project or whatever. All right. Cool. Awesome. There's a lot of information in there. Yeah, that was great. That was great. I think that gave us a great overview of many of the things you can do to get the full picture. People should go to your MVA course on GitHub. Codefosca.com, you can just go to MVA.Microsoft.com. We'll put the link up there. Yeah. All right, thanks so much. Absolutely. All right. Hope you enjoyed that and learned a lot. I know I did. And we will see you next time on Visual Studio Toolbox.