Skip to main content
Table of contents

Push documentation to GitHub

These instructions assume that you have documentation changes ready to push to GitHub.

To push your documentation changes to GitHub for the first time, you must:

  • create local and remote GitHub repos
  • commit all changes in the local repos
  • link the local repo to the remote repo
  • link the local master branch to the remote master branch
  • push the staged commit to the remote repo

Create local and remote GitHub repos

  1. Create a remote empty repo in your organisation on GitHub.

    You should select the following settings:

- no readme file
- no `.gitignore`
- MIT license
- yes to dependabot
  1. Create a new local documentation repo if required.

Commit all changes in the local repo

This initial commit happens on the master branch. You should use non-master branches for subsequent changes.

  1. Go to the local repo directory in the command line.

  2. Make the created local repo into a Git repo:

    git init
    
  3. If applicable, add all files in the local repo and stage them for commit:

    git add .
    
  4. Commit the staged files:

    git commit -m "COMMIT-MESSAGE"`
    

    where COMMIT-MESSAGE is the message describing the commit.

  1. Go to the remote repo in GitHub.

  2. Select the Clone or download button.

  3. Select either Use HTTPS or Use SSH.

  4. Select the copy button.

  5. In the command line, link the local repo to the remote repo:

    git remote add origin REMOTE-REPO-URL
    
  6. Verify the remote repo:

    git remote -v
    
  1. In the command line, rebase the local master branch on to the remote master branch:

    git pull --rebase
    
  2. Tell your local repo which master branch to refer to:

    git branch --set-upstream-to=origin/master
    
  3. Rebase again:

    git pull --rebase
    

Push the staged commit to the remote repo

Push the changes in your local repo to the remote repo:

git push -u origin master

You have now created a remote documentation repo on GitHub.

For more information, refer to Adding an existing project to GitHub.

This page was last reviewed on 3 October 2019. It needs to be reviewed again on 4 October 2019 by the page owner #docs-repos .
This page was set to be reviewed before 4 October 2019 by the page owner #docs-repos. This might mean the content is out of date.