Setup and Working with Git in Visual Studio Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
In the previous video, we used git from the terminal. Let's now do the same thing but from within Visual Studio Code. Let's go to the 'activity bar'. We see here the icon 'Source control'. Click on it. And you will see this as greyed out. Even though we have git available inside the 'MSYS2' system, Visual Studio Code needs it on the windows side. Let's go to 'install git'. Open the website. Go to 'Downloads'. We are on Windows right now. And it will download the installer. Open it. Next, next, next,..... Here we have the option where we set the default branch name. Override it, and set it to 'main'. Next. Here we have the option, which we also set in the terminal [previous video], to automatically convert between the windows type of linefeeds and the unix style. Next. I will leave most of these options as they are. Let's install it. It is now installed. Git comes along with a 'bash' shell. So let's launch it. I am going to make the font a bit larger. So in here, we can type the git command. The only option which we did not set yet, is the [git] identity. So we can do that. Set the 'user.name'. And let's also do that for the 'user.email'. Let's see all the options that we set over here including [from] the install. So most of the options are now in 'Program Files/Git/etc/config'. This one we also set in the terminal [in the previous video]. This one we set in the terminal [in the previous video]. And the default branch [name] we [also] set in the terminal [in the previous video]. The last two, we just added it, inside of the bash shell. And these are stored in our home folder in windows in the '.gitconfig'. We're now set. We can do inside Visual Studio Code a reload.... of the window. And now this option should be available to us. We can now click 'initialise'. we can see the same as that we did in the terminal but now we see the symbol 'U'.... for 'untracked'. We can add files. 'stage' them. And let's stage the... Makefile.... the 'main.f90' file.... and the 'README.md' [file]. So now, these three files are staged. In order to generate a '.gitignore' we need an extension. So let's look for that. Gitignore and we choose the one of 'CodeZombie.... Install.... We can now go to the 'command palette'. and look for 'gitignore'. Choose 'Add gitignore'. And first we gonna add the 'VS Code' It now creates a '.gitignore' [file]. We can view it. These are also the settings [for VS Code] which we also had in the terminal [previous video]. We can do it again. 'Add gitignore'. And now select the one for C++. Append. We now created the same '.gitignore' as before. Let's save it and go back over here. Also the '.gitignore', we can now... stage. We have these four files Go here to the message. 'Initial commit'. With enter we can continue on a second line To commit.....click on the commit button. We have now made the commit. we need an extension to view the 'git log'. Let's go to extensions Look for 'Git History'. Choose this one and install. We can go back to the 'command palette'. And we now.... have a 'Git View History' which is the same as 'git log'. We can now see our initial commit. The person that committed it. The commit identifier. So this is identical to what you have in the terminal. Let's do another commit. Change the file Fix a typo. Save the file. Go over here. You can see that file is modified. Stage the file. And add the commit message: 'Fixed typo'. And commit. Let's view the history again. Refresh. and see the two commits that we did Now let's push this to Github. I created a GitHub account. I logged in. But I didn't do anything else. So from Visual studio Code, We can now go over here. 'Publish to Github' The extension 'GitHub' wants to access the account. Allow. If you do this for the first time It will ask for your username and your password. I want to publish to theet private repository. It's now published. Let's go to GitHub. And see where our files are actually at. Let's go to... over here. We now have the 'GitDemo'. So VS Code created that for us. Click on it. And we can see our files. Let's make a modification from the GitHub site. Click on source. Click on the file. Click on edit. And make a modification. 'Update from GitHub'. and commit. This is done. Go back to Visual Studio Code. Over here we see various options. The option that we need was the 'pull'. 'push' is to push our changes into GitHub. 'pull' means: pull the changes from GitHub over here. We can see the [source] code updates. The change is now here. Let's view the 'git log'. And we can see our commit from GitHub. So all the steps did we did corresponds to the steps that we did in the terminal. But you can do the same thing from within Visual Studio Code. You could also still do the commands from the terminal so these two methods are compatible. So I hope this will help you out get started with git and GitHub with using Visual Studio Code.
Info
Channel: iRASPA
Views: 135,567
Rating: undefined out of 5
Keywords:
Id: Xe9OA18PF_o
Channel Id: undefined
Length: 9min 10sec (550 seconds)
Published: Thu Mar 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.