Initialize and Commit Repo0:00
Let's talk about Git now. So I will hit Ctrl-tilde to bring up the terminal. We will initialize Git, add everything, and immediately, as I do that, by the way, look in the sidebar to see how it reflects the change. You get that for free. Let's now commit with a message of install framework. And now those disappear. OK. So now I can run git log to see that. There we go.
View Diffs in Sidebar0:21
So now I can run a git log to see that. There we go. Oh, and by the way, you can hit Command-K at any time to clear the screen. So if you have a bunch of junk here, Command-K, and it's gone. Anyways, let's toggle that again with Ctrl-tilde. We'll go to that Member class. We'll make a change here. And now notice in the sidebar, once again, it instantly reflects that change there. And what's cool is I can click anywhere to view the diff. So for example, let's just imagine we return foo here.
Stage Changes in VS Code0:43
And what's cool is I can click anywhere to view the diff. So for example, let's just imagine we return foo here. And now Shift-Command-P, you'll see that we have all of these various git commands. Again, you can do it directly through the terminal. Generally, that's what I do, to be honest. But if you want, you could do it here. So we could stage all of the changes. And let's now view it. So I could go to View, down to Source Control. And here I can see all of the changes with a nice review here.
So I could go to View, down to Source Control. And here I can see all of the changes with a nice review here. And I can say whatever change I made here. And we're good. So now if I were to change that once again, that will immediately pop up in Source Control. So yeah, that's something you'll want to toggle whenever you need to. And again, by default, it will be set to Control-Shift-G. That's a little odd, but feel free to map that to whatever you want. So let's see the change we made now. Ah, we changed foo to foobar.
Enhance Git with GitLens1:32
So let's see the change we made now. Ah, we changed foo to foobar. And by the way, if you don't like side-by-side, you can switch it over to inline mode, which is what I often do. Now generally, this feature set is enough for me, but some people like to take it a step further, and they pull in a package called GitLens. So you can have a look here, and yeah, it basically just supercharges it. It gives you a lot more views for filtering down to specific commits, and your history, and all of that stuff. Yeah, and here you can see the git blame, which is cool.
Discard Changes and Reset2:24
Or if you want, you can discard all the changes by clicking this little refresh button. And now you'll see it defaults back to what we had before, and I'm sorry, we should have done controller there. So run that, and there we go. It defaults back. Pretty useful. So it's entirely up to you if you want to do it all from the terminal or through the UI.
