If you started a project locally, you can initialize a Git repository in VS Code and publish it to GitHub without opening a terminal or visiting the GitHub website. Initialize the repo, make your first commit, and create a remote repository in one workflow.
Make sure Git is installed and you are signed in to GitHub. If not, start with /vscode/how-to-set-up-git-in-vs-code-and-configure-your-name-and-email and /vscode/how-to-sign-in-to-github-from-vs-code.
Initialize a local Git repository
Open your project folder
Open the folder you want to track with Git. Use File > Open Folder and select your project directory.
Open the Source Control view
Press Ctrl+Shift+G (Windows/Linux) or click the branch icon in the Activity Bar. If the folder is not a Git repository yet, you will see a blue Initialize Repository button.
Initialize the repository
Select Initialize Repository. VS Code creates a .git folder in your project root.
A checkmark appears briefly, and the Source Control view changes to show your files under Changes.
You can also initialize through the Command Palette: press Ctrl+Shift+P (macOS: Cmd+Shift+P) and run Git: Initialize Repository.
After initialization, the Source Control view lists all files as Untracked (marked with a U).
The Status Bar shows the current branch name (usually main or master, depending on your Git default configuration).
Make your first commit
Before you can publish to GitHub, you need at least one commit. Stage and commit your files:
Stage your files
In the Source Control view, hover over the Changes header and select the + (Stage All Changes) button. Every file moves to the Staged Changes section.
Write a commit message
Type a message in the text box at the top of the Source Control view. Something like Initial commit works for the first one.
Commit
Select the Commit button. VS Code commits the staged files.
The Staged Changes list clears, and your commit is stored in the local Git history.
If you have a Copilot subscription, you can select the sparkle icon next to the commit message box to let AI generate a message based on your staged changes.
Publish to GitHub
Once you have at least one commit, the Source Control view shows a Publish to GitHub button (or Publish Branch in some versions).
Select Publish to GitHub
In the Source Control view, select the Publish to GitHub button. If you do not see it, open the Command Palette and run Git: Publish to GitHub.
Sign in if prompted
If you are not already signed in, VS Code opens your browser for GitHub authentication. Authorize and return to VS Code.
Choose public or private
VS Code asks whether you want a public or private repository. Public repositories are visible to everyone. Private repositories are visible only to you and collaborators you invite.
Confirm the files to include
VS Code shows a list of files that will be included. By default, all tracked files are included. Select OK to proceed.
VS Code creates a new repository on GitHub under your account, configures a remote named origin pointing to it, and pushes your commits. The Status Bar briefly shows the push progress.
After publishing, the Publish to GitHub button disappears and is replaced by the Sync Changes button. Your project is now live on GitHub.
Verify the published repository
Open your browser and go to github.com/<your-username>/<repository-name>. You should see your files and the commit message you wrote. The repository exists on GitHub exactly as if you had created it on the website and pushed from the command line.
Back in VS Code, the Status Bar shows the branch name with sync status. If it shows ↑0 ↓0, your local branch is in sync with the remote.
What if you already have a GitHub repository?
If someone already created a repository on GitHub and you want to connect your local project to it instead, get the repository URL from GitHub and run Git: Add Remote from the Command Palette. Enter origin as the remote name, paste the URL, and use Sync Changes to push your local commits.
Now that your project is on GitHub, learn how to /vscode/how-to-stage-commit-push-and-pull-changes-in-vs-code for the daily commit workflow.
Rune AI
Key Insights
- Use the Initialize Repository button in the Source Control view or the Git: Initialize Repository command.
- Make an initial commit before publishing so your repository has content.
- Use Publish to GitHub to create a remote repository and push your commits in one step.
- Choose public or private visibility when publishing.
- VS Code automatically sets up the
originremote pointing to your new GitHub repository.
Frequently Asked Questions
Can I publish to GitHub without signing in?
What if I already have commits and want to push them to an existing GitHub repository?
Can I choose between public and private when publishing?
What is the difference between Initialize Repository and Publish to GitHub?
Conclusion
You can turn any project folder into a Git-tracked repository and push it to GitHub without leaving VS Code. Initialize, make your first commit, and publish in just a few clicks.
More in this topic
How to Use VS Code with WSL 2 on Windows
Run VS Code connected to Windows Subsystem for Linux so you can develop in a full Linux environment with native tools, terminals, and debugging, all from Windows.
20 Best VS Code Extensions for Web Developers in 2026
Twenty carefully chosen VS Code extensions every web developer should know. Covers formatting, linting, frameworks, debugging, Git, and developer experience.
How to Install, Disable, Update, and Uninstall VS Code Extensions
Learn how to install, disable, update, and uninstall VS Code extensions from the Marketplace and the command line. Step-by-step instructions for every action.