Skip to content

How to Backup Files with Git using Visual Studio Code


This article will consist of information related to backing up notes to Github by way of Visual Studio (VS) Code.

Why Do This?

Git is a fantastic way of implementing version control in an environment. I started using VS Code just as a replacement for Sublime Text, but then realized I could use Git and connect it to my Github account.

How to Connect VS Code to Github

The steps I used to connect VS Code to Github are as follows:

  1. Create a directory on the local file system.
  2. Github --> Notes
  3. Create a repo on Github.
  4. Repo is called Notes
  5. Open the repo and clone it.
  6. git clone
  7. Open VS Code --> select File --> Add Folder to Workspace --> Select the Notes directory
  8. Open a Terminal Window in VS code and type the following:
git remote add origin{username}/{reponame.git}
git remote -v
git pull origin master

Wrapping Up

At this point, VS Code is now connected to that particular repo on Github. Any new documents created will be created in the Notes folder, unless otherwise specified. The process to commit changes to Github is listed below:

  • Save any changes to the notes (Ctrl + S)
  • VS Code will prompt that there are new changes to commit.
  • Stage the changes by clicking on the + symbol.
  • Once the changes have been staged, click the check mark for the Notes repo to commit.
  • VS Code will prompt for a commit message.
  • Provide a commit message and click Enter.
  • Look for the Source Control Provider list, find the repo in it and click the option for Synchronize Changes.

NOTE: A quick change that can be made to automatically synchronize changes is to navigate to Preferences --> Settings --> Extensions --> Git. Look for Post Commit Command and select Sync