There are two methods I use to push code to GitHub. Method 1. Visual Studio Code. Method 2. Git Bash. Both are effective and I know people who use one over the other all the time. In this article I will walk through cloning your repo in GitHub locally via HTTPS, clone the repo, and then push changes to your GitHub repo via Visual Studio Code.
If you are looking for my blog article on how to do the above via Git Bash, please go to this URL:
https://digitalthoughtdisruption.com/2020/09/09/clone-repository-push-changes-using-git-bash/
If you are looking for an article on how to create the GitHub repository please see the following link:
https://digitalthoughtdisruption.com/2020/09/09/create-a-repository-in-github/
Step by Step Process:
Go to https://www.github.com
Go to the repository you have already created – my example is vscodeexample

Click on code and grab the Clone with HTTPS URL
Then open the Git Bash

$ la -la
This will show nothing is in the /vscode/externalprojects folder I created earlier
$ git clone <contents from clipboard>
This will clone the repo locally
$ ls
This will now show the repo that was created on GitHub on your local machine

Go into VS Code and click File > Open Folder

Select the folder then select folder

As you can now see you are in this folder in VS Code

File > New File

I put some basic text in here

File > Save

I gave it a name and put .ps1 at the end to make it a powershell script to show you something later

Shows your untracked changes

Click the + sign to stage changes

Select the check mark to commit the changes

Enter the message you want associated with this commit

Click the synchronize changes button next to master

OK

The wheel will spin until changes have been pushed

If you have not done so already I recommend clicking Yes

When you refresh the GitHub repo you should see the new file and under Languages it even says that so far 100% of the files are in PowerShell
Summary:
As you can see linking a repo and pushing updates from your local VS Code to your central repo on GitHub is pretty easy once you know what you are doing. As always, I hope y’all found this useful.
2 comments