Here are the detailed steps needed to achieve this.

The existing commands can be simply run via the CLI terminal of VS-CODE. It is understood that Git is installed in the system, configured with desired username and email Id.

  1. Navigate to the local project directory and create a local git repository:

    git init

  2. Once that is successful, click on the 'Source Control' icon on the left navbar in VS-Code.One should be able to see files ready to be commit-ed. Press on 'Commit' button, provide comments, stage the changes and commit the files. Alternatively you can run from CLI

    git commit -am "Your comment"

  3. Now you need to visit your GitHub account and create a new Repository. Exclude creating 'README.md', '.gitIgnore' files. Also do not add any License to the repo. Sometimes these settings cause issue while pushing in.

  4. Copy the link to this newly created GitHub Repository.

  5. Come back to the terminal in VS-CODE and type these commands in succession:

    git remote add origin <Link to GitHub Repo> //maps the remote repo link to local git repo

    git remote -v //this is to verify the link to the remote repo

    git push -u origin master // pushes the commit-ed changes into the remote repo

Note: If it is the first time the local git account is trying to connect to GitHub, you may be required to enter credentials to GitHub in a separate window.

  1. You can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online.
Answer from Vikram K on Stack Overflow
Top answer
1 of 16
219

Here are the detailed steps needed to achieve this.

The existing commands can be simply run via the CLI terminal of VS-CODE. It is understood that Git is installed in the system, configured with desired username and email Id.

  1. Navigate to the local project directory and create a local git repository:

    git init

  2. Once that is successful, click on the 'Source Control' icon on the left navbar in VS-Code.One should be able to see files ready to be commit-ed. Press on 'Commit' button, provide comments, stage the changes and commit the files. Alternatively you can run from CLI

    git commit -am "Your comment"

  3. Now you need to visit your GitHub account and create a new Repository. Exclude creating 'README.md', '.gitIgnore' files. Also do not add any License to the repo. Sometimes these settings cause issue while pushing in.

  4. Copy the link to this newly created GitHub Repository.

  5. Come back to the terminal in VS-CODE and type these commands in succession:

    git remote add origin <Link to GitHub Repo> //maps the remote repo link to local git repo

    git remote -v //this is to verify the link to the remote repo

    git push -u origin master // pushes the commit-ed changes into the remote repo

Note: If it is the first time the local git account is trying to connect to GitHub, you may be required to enter credentials to GitHub in a separate window.

  1. You can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online.
2 of 16
66

This feature was added in 1.45, demoed here.

Launch the command palette Ctrl+Shift+P, run Publish to Github, and follow the prompt. You will be given the choice between a private and public repository, so be careful that you choose the right one.

It may ask you to login to github. It will then prompt for the repo name (defaults to the name of the folder), and for creating a .gitignore file (defaults to empty .gitignore). Just hit enter if you are fine with the defaults. When you are done it should give you a popup notification in the bottom right with a link to the repo https://github.com/<username>/<reponame>

Minor warning: if your project already has a .gitignore file in it this process will overwrite it

🌐
Techielass
techielass.com › how-to-push-code-from-vs-code-to-github
How to push code from VS Code to GitHub
October 23, 2025 - ... Once created, copy the repository's URL from the quick setup section. ... Switch back to your VS Code editor. Click on the ellipsis (...) in the source control view, select Pull/Push from the drop-down menu, and choose Push to.
Discussions

Using github and VS Code?
Step by step tutorials: https://vscode.github.com/ More on reddit.com
🌐 r/webdev
23
16
May 8, 2024
Can't do initial commit and push from VS Code to private GitHub repo
It might be worth reporting it in the extension's issues. To move forward, if you visit the empty repo on Github, it will give you a list of commands to run in the terminal to push up your repo More on reddit.com
🌐 r/vscode
5
1
October 24, 2023
How to easily move a VSCode git repo to github?

I couldn't find a built in way in VSCode, so you'll have to do a little command line magic, but it's not too hard. (Forgive me, not on Windows so the procedure might be slightly different for you in ways I can't predict, but I hope not).

First, from your VSCode project, open the terminal window. For me, that keyboard shortcut is CTRL-` (control + backtick). From the terminal, type git remote -v. This should return nothing since you don't have a remote repository (it should also tell you whether you properly have git installed). Next, the command you want is git remote add origin git@github.com:youruser/yourproject.git. Obviously replace with your username and project name from whatever you made in github. Then, push all your history up to github with git push -u origin master. Now, if you type git remote -v it will show you connected to your remote. You can close the terminal window now.

From here on, when you commit code in VSCode, you should also consider "pushing" to GitHub. This can be done by clicking the little ellipsis (...) icon in the source control extension and choosing push after your commits.

EDIT: It might also help to know that GitHub already teaches you the commands to do this when you make a new empty repo (ie: one with no README.md file).

…or push an existing repository from the command line

git remote add origin git@github.com:yourname/blankrepo.git

git push -u origin master

More on reddit.com
🌐 r/vscode
3
5
August 17, 2019
help me set up github on vscode to push my code directly on github please.
Do you have the github plugin? That makes it easier. More on reddit.com
🌐 r/github
7
0
September 20, 2024
🌐
GitHub
github.com › sailesh307 › GitHubTutorial
GitHub - sailesh307/GitHubTutorial: In this tutorial, you will get to know how to upload files or Projects step by step to GitHub using VSCode (the simplest way) · GitHub
In this tutorial, you will get to know how to upload files or Projects step by step to GitHub using VSCode (the simplest way) - sailesh307/GitHubTutorial
Starred by 65 users
Forked by 19 users
🌐
Visual Studio Code
code.visualstudio.com › docs › sourcecontrol › quickstart
Quickstart: use source control in VS Code
November 3, 2021 - To pull or push individually, select ... with a local folder (Option B) and want to save it to GitHub, use the Publish to GitHub button in the Source Control view....
🌐
Everhour
everhour.com › github › how to push to github: complete step-by-step guide
How to Push to GitHub from VS Code or Terminal
December 22, 2025 - Yes, use the Source Control panel or Git terminal in VSCode. Use git add, git commit, then git push to update the repo. Initialize Git in the folder and connect it to your GitHub repo. Track time, stay on budget, analyze reports and automate payroll
🌐
JC Chouinard
jcchouinard.com › accueil › how to commit and push code to github repository (vs code example)
How to Commit and Push Code to Github Repository (VS Code Example) - JC Chouinard
April 4, 2025 - Click on the ellipsis menu and choose “Push” to push your changes to your remote GitHub repository. That’s it! Your changes should now be visible in your GitHub repository. Although very powerful, Git is very complex.
🌐
Graphite
graphite.com › guides › how-to-push-code-from-vscode-to-github
How to push code from VS Code to GitHub - Graphite
Learn the steps to push your code from Visual Studio Code to your GitHub repository, including setup, committing, and using both the VS Code UI and terminal.
🌐
Visual Studio Code
code.visualstudio.com › docs › sourcecontrol › github
Working with GitHub in VS Code
November 3, 2021 - Once you select Create, if you have not already pushed your branch to a GitHub remote, the extension will ask if you'd like to publish the branch and provides a dropdown to select the specific remote.
Find elsewhere
🌐
Reddit
reddit.com › r/webdev › using github and vs code?
r/webdev on Reddit: Using github and VS Code?
May 8, 2024 -

Hey everyone!

I know i’m going to sound pretty stupid for this but i’ve looked all over youtube and all of the videos are from years ago or don’t really explain it well in my opinion. Can someone here explain to me in the most basic terms how to use github and vs code together so that i’m able to access my code from both my laptop and desktop

update: thank you so much everyone! i was able to figure it out

🌐
GeeksforGeeks
geeksforgeeks.org › git › gitpush-with-visual-studio-vs-code
GitPush With (Visual Studio) VS Code - GeeksforGeeks
July 23, 2025 - Step 8: These are the changes made in the local system but we want to upload the project which we created in your system to GitHub then follow the below steps to upload :
🌐
GitHub
github.com › orgs › community › discussions › 60382
Regarding uploading the code developed on my Github repository · community · Discussion #60382
July 8, 2023 - Then, click on the ellipsis (...) in the Source Control panel and choose "Push" to upload your local changes to the remote repository. VSCode will handle the authentication process if necessary, prompting you to provide your Git credentials.
🌐
Medium
medium.com › @shouke.wei › how-to-push-a-project-to-github-from-vs-code-no-stress-4aa83ce197a4
How to Push a Project to GitHub from VS Code (No Stress!) | by Dr. Shouke Wei | Medium
July 4, 2025 - Whether you’re building a side project, learning Git for the first time, or just want to save your code in the cloud, uploading a project to GitHub is a crucial step. Visual Studio Code makes this easier than ever with its built-in Git integration. In this post, I’ll walk you through how to push your local project to a new GitHub repository directly from VS Code using both the terminal and the built-in UI.
🌐
Visual Studio Code
code.visualstudio.com › docs › sourcecontrol › intro-to-git
Introduction to Git in VS Code
November 3, 2021 - To pull or push individually, select ... with a local folder (Option B) and want to save it to GitHub, use the Publish to GitHub button in the Source Control view....
🌐
Visual Studio Code
code.visualstudio.com › docs › sourcecontrol › overview
Source Control in VS Code
November 3, 2021 - You can publish a local repository directly to GitHub with the Publish to GitHub command, which creates a new repository and pushes your commits in one step.
🌐
DEV Community
dev.to › cyberhack08 › how-to-push-your-code-from-visual-studio-local-to-github-using-git-the-terminalbeginners-2n5m
How to Push Your Code from Visual Studio (Local) to GitHub Using Git the Terminal.[Beginner's Guide] - DEV Community
November 9, 2025 - 2. To push your code to your GitHub account, use the command "git push -u origin main" You would be asked to enter your Username: Your GitHub username, and Password: That’s the token you created earlier when you created your new repository.
🌐
DevGenius
blog.devgenius.io › how-to-add-your-project-to-github-with-visual-studio-code-b311b57ad9d0
How to Add Your Project to GitHub with Visual Studio Code | by MP Codes | Dev Genius
October 6, 2023 - In this tutorial, we’ll walk you through the process of pushing your project to GitHub using Visual Studio Code, a popular code editor. Follow these steps, and you’ll have your code safely stored on GitHub in no time.
🌐
TutorialsPoint
tutorialspoint.com › how-to-upload-a-project-to-github-from-vs-code
How to upload a project to GitHub from VS Code?
November 1, 2023 - Creating an account on GitHub is the next step. Do it by visiting here ... 4. Copy the URL of your repository once it has been created. With this URL, we can push code to this repository from Visual Studio Code. Step 4 ? Open the folder you wish to push in Visual Studio code.
🌐
Techloy
techloy.com › how-to-push-changes-to-github-from-vs-code
How to push changes to GitHub from VS code
March 21, 2025 - First, go back to your GitHub account, open the repository, and copy the Repository URL. On your VS Code Editor, Click on the ellipsis in the source control view, select Pull/Push from the drop-down menu, and choose Push to.
🌐
Medium
faizahsalami1.medium.com › a-beginners-guide-to-pushing-codes-from-vs-code-to-github-using-git-part-1-fbea7bb482f
A Beginner’s Guide to Pushing Codes from VS Code to GitHub using Git (Part 1) | by Faizah Salami | Medium
September 27, 2022 - Not to worry, in this article, I will try to work you through the steps of pushing your project using the VS Code built-in terminal. ... To start with, Git and GitHub are not the same. Git is a version control system that makes it easy for developers to create different versions and track changes made to a project.
🌐
DEV Community
dev.to › rembertdesigns › learn-how-to-push-code-from-vscode-to-github-3klh
Learn How To Push Code From VSCode To GitHub - DEV Community
September 15, 2022 - Step 10: If you’re pushing the code for the first time, it will show you a popup to log in on Github. So Enter your Github account credentials and click on “log in.” · The code is now successfully delivered to Github from VSCode.