4 minute read

Overview

header

This is the second post in a series of articles, that are aimed at showing you simple step by step guides to creating your own static website hosted on GitHub for free. This post focuses on setting up VSCode and Git. I’ll show you how to install and configure them, then we’ll connect to our GitHub repository. If you’re not sure what Git is and why it makes sense to use it, then this is a good article that explains the basics.

The starting point for this series of guides is here. The first article explaining how to set up a GitHub account is here. in case you need to do that.

Install VSCode on Windows 10

First of all lets grab the latest version of VSCode. For Windows you have two choices, either download from the Microsoft site here or use PowerShell.

Let’s keep it simple and download via the browser. Go to the URL above and then click on the relevant blue box for your setup:

vscode-download

For me it’s Windows 10, I clicked on the box on the left, and Edge downloads the setup exe:

vscode-setup

Once downloaded click run, depending on which account your logged on as you might get this warning:

vscode-nonadmin

If you want to install as Administrator click ok, otherwise cancel and log on with the user you want to use. At the license agreement choose I accept the agreement and click Next:

vscode-license

Choose where you want to install VSCode, then click Next:

vscode-location

Choose if you want a Start Menu shortcut and where, then click Next:

vscode-startmenu

Choose any additional settings, and then click Next:

vscode-tasks

Review your choices, and then click Install:

vscode-choices]

Wait while VSCode is installed:

vscode-install

After installation click Finish to start VSCode:

vscode-launch

You now have VSCode installed, and ready to configured:

vscode-startup

You’ll need to have already set up your GitHub account and repository before proceeding with the following install and configuration of Git. Follow my previous guide here. if you still need to do that, then come back and follow on with the below.

Installing Git

On Windows 10 you will need to install Git, so you can connect your VSCode workspace to your GitHub repository. Download Git for Windows from here and run it. Read the license and then click Next:

git-setup

Choose where you want it installed, then click Next:

git-location

Select which components you want to install, I leave the defaults, then click Next:

git-components

Choose if you want a Start Menu folder creating, and where, then click Next:

git-startmenu

On the Choosing default editor screen change it to Use Visual Studio Code, and click Next:

git-vscode

On the adjusting path screen leave the default recommended option, and click Next:

git-path

On the HTTPS selection screen leave the default OpenSSL option, and click Next:

git-https

On the configure line ending conversion screen leave the default, and click Next:

git-lineendings

If installing Git on Windows 10 the you can change the terminal to use the default console window, then click Next:

git-terminal

On the git pull behavior screen leave the default selection, and click Next:

git-pull

On the Git credential helper screen leave the default middle option, or you can use the bottom option to install the new Core version. Either works with Windows 10, after selecting click Next:

git-creds

On the configuring extras screen leave caching enabled, and then click Next:

git-extras

On the experimental options screen leave pseudo console disabled, and then click Install:

git-experiment

Wait while Git is installed:

git-install

Select Launch Git Bash, and click Next:

git-launch

You’ll now see your Git Bash window:

git-bash

The files we create and edit in VSCode will be kept in our local Git repository. We can connect this to GitHub and store our credentials. VSCode will then use these to synchronize your local files with your remote GitHub repository, without you needing to log in each time.

Configure Git

First make a new folder to use as your local workspace:

workspace

In the Git Bash window we need to set the username we’ll use to connect to GitHub:

git-username

This is the same username we used to set up our GitHub account in the last guide. Next we set the email address we used:

git-username

Now we change directory in to our workspace folder:

git-workspace

Finally we can clone our remote repository down to our local workspace:

git-clone

If we CD in to that cloned repository, we see the files match what we have on the GitHub site:

git-local-files

Here’s how our repo looked on GitHub when created it in the previous guide:

github-repo

Configure Workspace

Now we have our remote GitHub repository cloned to our local Git instance. Let’s go back to VSCode and click on Add workspace folder:

vscode-add-workspace

Browse to the folder where we cloned our GitHub repository, and click Add:

vscode-add-folder

Clicking on the Explorer tab on the left shows our files in the workspace folder:

vscode-new-workspace

Let’s save the workspace, so later we can change some of its settings:

vscode-save-workspace

Choose a name for the workspace configuration file and where you want to save it:

vscode-name-workspace

Run a sync to ensure all local files are up to date:

vscode-git-sync

Click OK to run the sync:

vscode-confirm-sync

Doing this also gets VSCode to ask you to enable periodic fetches:

vscode-periodic-git-fetch

Create and publish test file

Now let’s create a test file:

vscode-test-file

Add anything as content:

vscode-test-text

Run another sync:

vscode-command-palate

Choose to save and commit the file:

vscode-test-commit

Choose Yes to automatically stage all change:

vscode-test-stage

Enter a meaningful message to the commit:

vscode-test-commit-message

Now push your changes to GtiHub:

vscode-test-push

If this is the first time you’ve pushed to GitHub you’ll need to enter your credentials:

github-login-credentials

If you look at the repository on GitHub you should see the newly committed test.md file:

github-test-check

That’s it for our installation and configuration of VSCode and Git.

Summary

So in this post we’ve looked at grabbing the latest version of VSCode, and Git. We’ve installed and configured them, and connected to our remote GitHib repository. Next time we’ll look at some of the useful extensions that you can install in VSCode, which turn it in to a comfortable writing environment.

Comments