• Install Git for Windows from
  • Install Visual Studio Code from
  • Have a GitHub account and be logged in.
  • Have an existing project folder that you want to version control and share on GitHub.

Step 1: Configure Git to Use ‘main’ as Default Branch

  1. Open VSCode.
  2. Open the integrated terminal by going to Terminal -> New Terminal or using the shortcut `Ctrl+“ (backtick).
  3. Run the following command: git config --global init.defaultBranch main This sets ‘main’ as the default branch for all your new Git repositories.

Step 2: Initialize Your Local Project with Git

  1. Open your project folder in VSCode: File -> Open Folder and select your project directory.
  2. In the integrated terminal, initialize the repository: git init
  3. Add all files to your new local Git repository: git add .
  4. Commit the files to save the current state to your local Git history: git commit -m "Initial commit"

Step 3: Create a New Repository on GitHub

  1. On GitHub, click the “+” icon in the upper-right corner and select “New repository”.
  2. Name your repository, set it to public or private, and skip the initialization options.
  3. Click “Create repository”.

Step 4: Add Your GitHub Repository as a Remote

  1. After creating the repository, copy the repository URL from GitHub.
  2. Back in VSCode’s terminal, add the GitHub repository as a remote: git remote add origin YOUR_REPOSITORY_URL Replace YOUR_REPOSITORY_URL with the one you copied.

Step 5: Push Your Project to GitHub

  1. Push your main branch to GitHub: git push -u origin main
  2. If prompted, enter your GitHub credentials (username and personal access token).

Checking Status and Troubleshooting with VSCode

  • Use VSCode’s Source Control side panel to check the status of changes, stage files, and commit.
  • To check the list of remotes, you can click on the “…” in the Source Control side panel and select “Remotes”.
  • For SSL certificate issues on Windows, you can use the Windows Credential Manager to manage your Git credentials.

Common Issues:

  • No Changes Detected: Make sure you have opened the correct folder in VSCode that contains your project files.
  • Remote Not Added: If VSCode’s Source Control doesn’t show the remote, double-check the remote URL and try adding it again.
  • Authentication Issues: In case of a two-factor authentication setup on GitHub, use a personal access token instead of your GitHub password.
  • Push Rejected: If VSCode shows a push rejected error, pull the latest changes first using the “Pull” command in the Source Control side panel and merge any changes if needed.

Now your project is under version control with Git, and your main branch is pushed to GitHub, all from the comfort of VSCode on Windows. You can now continue to manage your project, make new commits, and push changes directly from VSCode’s friendly UI. If you have any questions or encounter issues, VSCode’s integrated terminal is a powerful tool for more complex Git operations and troubleshooting.