GitHub: Push to a Remote Repository

Free Git Tutorial

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.

git distributed workflow diagram

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)

  1. 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

  2. Open your local Git repo folder in Visual Studio Code.
  3. At the bottom left of the VS Code window, click the Publish to GitHub button publish to github.
  4. 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

      1. Switch back to Visual Studio Code.
      2. Hit the Esc key.
      3. At the bottom left of the window, in the blue bar click Signing in to github.com.
      4. Hit the Esc key.
      5. 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 publish to github.
      6. Click Allow.
      7. 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.

  5. 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.

  6. 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.
  7. 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!

  8. Switch back to Visual Studio Code and you can continue your work.
  9. 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.

Full-Stack Web Development Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

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 synchronize button to pull and then push (we explain what pulling is in the next exercise).

  • At the top right of Source Control panel vscode soure control icon click the More Actions button vscode more actions icon and from the menu choose Push.

photo of Dan Rodney

Dan Rodney

Dan Rodney has been a designer and web developer for over 20 years. He creates coursework for Noble Desktop and teaches classes. In his spare time Dan also writes scripts for InDesign (Make Book JacketProper Fraction Pro, and more). Dan teaches just about anything web, video, or print related: HTML, CSS, JavaScript, Figma, Adobe XD, After Effects, Premiere Pro, Photoshop, Illustrator, InDesign, and more.

More articles by Dan Rodney

How to Learn Git

Master Git with hands-on training. Git is a free, open-source version control system that allows developers to track the changes they make to code.

Yelp Facebook LinkedIn YouTube Twitter Instagram