fbpx

Basic Setup Guide for Using GitHub With Visual Code and PowerShell

This guide is a complete beginners guide to creating an account on GitHub and setting up somewhere to store your code and then linking that to Visual Code which is a cool free Microsoft tool used to write code. I’ll like to leave out the fluff and filler so ill keep the text brief, so follow along and use the screenshots for reference.

By the end of this guide you will know how to:

  • Create GitHub repositories for your code projects.
  • Download code repositories to a working folder on your computer.
  • Create and update files and commit the changes into a GitHub repository.

Let’s get started!

Signup for a GitHub account

Go here and sign up for a free GitHub account https://github.com/

Choose a suitable username because it will become part of your GitHub web address.

Choose the free plan for now.

Next you are given the opportunity to create your first repository. A repository is a place to store code for one project. If you have multiple projects you can add multiple repositories. Here I create a new repository ‘Social Counter’ for a PowerShell project I’ve been working on.

It’s a good idea to add a detailed description so that you and others know what it’s about.

Next choose a Public or Private repository. Public means anyone can find it on the internet by searching for it and can contribute to it. I chose Public here but you can make a private one if you wish.

Finally I prefer to initialise the repository with a readme file. In the readme you can explain the project in detail and include any special notes required to work on the project or to get it working.

You will now be presented with the main dashboard for the repository. Only bit worth mentioning here is that the list of files will be visible and if you click on the readme it will display the contents. You can edit files directly on the GitHub page if you want to make quick changes.

Install GIT for Windows

Since Windows doesn’t yet ship with a built in GIT handler we need to install one. If you don’t know, GIT is a version and control system which let’s you manage changes to code and commit changes which can then be merged into a repository. GIT doesn’t actually stand for anything, it’s a tool set developed by the famous Linus Torvalds who needed a way to manage all of the code changes made to the Linux Kernel .

Grab the windows version from here: https://gitforwindows.org/

Accept all defaults except for the two screen shot options below:

Install Visual Code

Now we can install Microsoft’s Visual Code tool from :

https://code.visualstudio.com/

Accept all defaults although I prefer to select all options on this page:

Setting IT All Up

Fire up Visual Code and you should see a dashboard like this.

The first thing we need to do is set a working folder to store our repositories. Click on Open Folder as shown below:

I created a ‘WorkSpace’ folder in my documents folder.

Next click Terminal then ‘New Terminal’ to show the terminal window in the workspace. We need this terminal window in a bit to enter some GIT commands.

Go back to your GitHub account and go into the repository. You should see a bit green button saying ‘Clone or download’. Click on this and copy the repository URL.

Now go back to Visual Code and enter these commands into the terminal:

git clone <enter the repository URL here>
git config –global user.name “<enter your GitHub username here”
git config –global user.email <enter your email address here>

You should see output similar to that in the screenshot below. The GIT system will download all of the files in the repository into your WorkSpace folder. You will see on the left panel that the readme file has been downloaded and if you click on it, it opens up.

So now we have a downloaded copy of the respository code on your computer. Let’s make a change to the readme file and upload the changes into GitHub.

Open the readme file and made a change to it. Here I add some more details and save the file.

One the left hand menu you will see a blue circle has appeared on the ‘SourceControl’ icon after saving the file. This is indicating that changes need committing so that they can be properly saved into the project.

Click on the source control icon and you will see a text box at the top.

In the box you can enter a brief description about the changes you have been making. Here I enter ‘Updated readme’ and next pressed the tick icon to commit the changes to the project.

If prompted click ‘Always’. This is basically saying we haven’t chosen which files are OK to commit. At the moment we just want to commit ALL changes that we’ve made so this if fine.

All changes have been committed to the project but we still have to upload them to our GitHub repository.

To do this click the little circle icon in the bottom left of the program. Click ‘OK Dont show again’ if the message box pops up.

You will be prompted the first time you do this to sign into your GitHub account.

Once the uploads finish you can go to your GitHub dashboard and harray!! you will see the changes have been saved back to your online repository!

Switch back to Visual code and right click the repository name and select ‘new file’ and enter the full name of a new file. Here I use SocialCounter.ps1 to create a new PowerShell file.

I add a single comment to the PowerShell file and now let’s try committing and uploading this new file into the online GitHub repository.

As before click the Source Control icon, Add a quick comment describing the changes and press the tick icon to commit all changes. Then click the sync icon in the bottom left.

Switch back to your online GitHub repository and you will see the new PowerShell file listed!

Click on the file to view the code it contains.

Conclusion

Congratulations on creating your first GitHub repository and connecting Visual Code to it for working on your projects.

GitHub is a great place to store your projects especially if you want to work on them with multiple people or just by yourself but from multiple devices or locations.

If you found this useful please share with others and leave a comment 🙂

Author: Ian@SlashAdmin

Share This Post On
468 ad

Submit a Comment

Your email address will not be published. Required fields are marked *

slashadmin \ life in it