Learn how to efficiently create a remote repo on GitHub, upload your local repository, and push your changes for effective collaboration with other developers in this detailed guide.
This exercise is excerpted from Noble Desktop’s Git & GitHub training materials and is compatible with updates through 2022. To continue learning web development with hands-on training, check out our coding bootcamps in NYC and live online.
Pushing (Uploading) Your Changes: Remote Repositories & GitHub Explained
When you have a local repository that you want to share with others (or create an online backup), you need to create a remote repo on a service like GitHub so you can upload (push) your files and revision history to it.
Storing a copy of your Git repo with an online host such as GitHub (which is run by Microsoft) gives you a centrally located place where you can upload your changes and download changes from others. This lets you collaborate with other developers, and serves as a backup of your code (and the Git history of changes).
Push for the First Time to Create a New GitHub Repo (Publishing from Visual Studio Code)
Windows Users Only: To ensure GitHub’s authorization will work with VS Code, you must set your your default browser Google Chrome. For instructions on how to do that visit tinyurl.com/def-brow
- Open your local Git repo folder in Visual Studio Code.
- At the bottom left of the VS Code window, click the Publish to GitHub button
.
-
If this is the first time you’re using GitHub in VS Code you’ll see a message wanting to sign into GitHub, click Allow and:
- In the web browser that opens, when asked to Authorize Visual Studio Code, click Continue.
- If asked, sign into your GitHub account.
-
Click Authorize github. If you get an error, do the sidebar below.
If An Error Occurred
- Switch back to Visual Studio Code.
- Hit the Esc key.
- At the bottom left of the window, in the blue bar click Signing in to github.com.
- Hit the Esc key.
- Now we can try again (it often works the second time). At the bottom left of the VS Code window, click the Publish to GitHub button
.
- Click Allow.
- In your web browser, click Continue and hopefully this time it works! Proceed with the remaining steps below.
- If asked about allowing this page to open Visual Studio Code, click Allow, Open Visual Studio Code, or whatever your browser says.
Back in Visual Studio Code, if you’re asked to allow an extension to open this URI click Open.
-
In the panel that appears at the top of the window, choose Publish to GitHub private repository.
NOTE: You could use a public repository if you want anyone to be able to see and contribute to it, such as and open source project.
-
At the bottom right of the window you’ll see the upload progress. During the upload, if you’re asked to sign into GitHub, click Sign in with your browser:
- Switch back to your web browser and click Authorize GitCredentialManager.
- When you see Authentication Succeeded switch back to Visual Studio Code.
-
At the bottom right of the window you’ll see the upload progress. When it’s done click Open on GitHub.
Your web browser will open and you’ll see your remote repo!
- Switch back to Visual Studio Code and you can continue your work.
If you’re asked Would you like Code to periodically run ‘git fetch’? (at the bottom right of the VS Code window) we recommend clicking No.
How You Typically Push Changes to GitHub
Once the local Git repo knows about the remote repo (GitHub), you can use the Push command. Here are some different ways to do that:
At the bottom left of the Visual Studio Code window (in the blue bar), click the Synchronize Changes button
to pull and then push (we explain what pulling is in the next exercise).
At the top right of Source Control panel
click the More Actions button
and from the menu choose Push.