Add Project to Source Control

The Activity Bar enables you to initialize a repository from a project and publish the repository to GitHub. Alternatively, Open the Command Palette (⇧⌘P) and search for "git" to view git commands.

You must have a GitHub account as a prerequisite to adding a project to a GitHub repo.

To add a project to a GitHub repo:

  1. Click the Source Control icon (Source Control icon) in the Activity Bar.
  2. Click Initialize Repository.
  3. In the Message field, add a commit message, such as "initialize project repo".
  4. Click Commit.
  5. Click Yes in the window asking "Would you like to stage all your changes and commit them directly?"
  6. Click Open Git Log in the window that says "Make sure you configure your "user.name" and "user.email" in git."
  7. Click the Terminal subtab and run the following commands after you substitute values for you@example.com and Your Name:
  1. In the Activity Bar, enter the commit message again and click Commit.
  2. Click Publish Branch.
  3. Click Allow in the window that says "The extension 'GitHub' wants to sign in using GitHub."
  4. Click Copy & Continue to GitHub.
  5. Click Open to open GitHub in your browser.
  6. Paste the copied code and click Continue.
  7. If prompted for Single sign-on to your organizations, click Continue.
  8. If prompted, click Authorize Visual-Studio-Code.
  9. Complete logging in to GitHub. If two-factor authentication is configured for your GitHub account, you may be asked for a two-factor code.
  10. In VS Code, choose to "Publish to GitHub private repository". Alternatively, choose "Publish to GitHub public repository" if you want to make the repo available to anyone. If in doubt, choose the private repo.

Your project is now saved in GitHub.