From the course: Visual Studio: Source Control with Git and GitHub

Commit to local: VS - Visual Studio Tutorial

From the course: Visual Studio: Source Control with Git and GitHub

Start my 1-month free trial

Commit to local: VS

- [Instructor] Let's revisit the commit action in Git. I want to show you some extra nuances in Visual Studio. So I'm in Solution Explorer and I can see that I've made some changes in TourStop. I've made a couple minor changes in here and Visual Studio indicates there's a change in two places, it puts a red check mark here saying there's a pending edit and up in the file itself, there's an asterisk here which means I have not saved this file yet. So even though it hasn't been saved, Visual Studio knows that there's a possible commit necessary. To make the commit, I can bring up the Commit screen in several ways. I can right click on this file and choose Commit and that takes me over to the Team Explorer and the Changes section and it's asking me whether I want to commit or not. And it's telling me that I'm going to commit this one file. And if I have more than one file, I can also go to the project level, right click and choose Source Control, Commit. That takes me to the same screen. And I can do it a third way by going to the solution. That'll take me to the screen and of course, if you want, in team Explorer, you could go directly to Changes and you get the same screen. So there's four ways we've seen to get to this screen. Now I'll enter my commit message here. And then I would go here and choose Commit All but before I do that, let's go take a look in PowerShell. We'll run git status and it comes back and it says there's no pending changes. Why is that? Remember that you have to call a git add to add the final to the index to indicate that it's been changed and here's what's happened. Visual Studio hasn't saved the file yet so Git doesn't know that it's been changed. So I'll go back over to Visual Studio and there's a couple of things I can do. If I were to choose Commit All now, Visual Studio will notice that this file has not been changed and will ask me if I want to save the file. And once it's been saved, then it'll show up in the status. So let's go ahead and manually save it. When I return back to PowerShell and run that command again, git status, I see that I've modified this file. And of course, if I was in PowerShell, I could do git commit but we'll do this from Visual Studio and choose to Commit All. And it says I've committed this change. There's the identifier for this. It's been created locally and it knows I have a remote repository so it's also suggesting that I might want to synchronize so that my changes on my local are propagated to the remote.

Contents