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.
Navigate to the local project directory and create a local git repository:
git initOnce 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"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.
Copy the link to this newly created GitHub Repository.
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 repogit remote -v//this is to verify the link to the remote repogit 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.
- You can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online.
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.
Navigate to the local project directory and create a local git repository:
git initOnce 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"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.
Copy the link to this newly created GitHub Repository.
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 repogit remote -v//this is to verify the link to the remote repogit 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.
- You can see the success message in the Terminal. You can also verify by refreshing the GitHub repo online.
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
Using github and VS Code?
Can't do initial commit and push from VS Code to private GitHub repo
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
More on reddit.com
git push -u origin master
help me set up github on vscode to push my code directly on github please.
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