Skip to main content
Dan Rodney/4 min read

GitHub: Push to a Remote Repository

Resolve a Merge Conflict

1

Identify Conflicts

git status shows files with conflicts after a failed merge.

2

Open the Files

Look for <<<<<< / ====== / >>>>>> markers — your changes vs theirs.

3

Edit & Stage

Pick the right code, remove markers, git add the file.

4

Complete the Merge

git commit finalizes the merge with the resolved content.

Build Programming Foundations at Noble Desktop

Noble Desktop's Full-Stack Web Development Certificate teaches Git alongside the modern web stack — a must for any developer.

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.

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)

  1. Windows Users Only: To ensure GitHub’s authorization will work with vs. Code, you must set 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 .
  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 .
      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.

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.