top of page
  • Writer's pictureTaylor Hickem

Contributing to a Github repository

Updated: Jan 8, 2022

Github is a popular collaborative platform for programming. Files for a project are stored in repositories (repos) that are publicly accessible. Github users can contribute to growing and improving the repos through a process of fork-branch-edit-pull-merge. Scott Lowe has published a helpful tutorial for the fork and branch workflow.


This short article presents similar information from Scott's post and is a step-by-step instructions for publishing updates to an existing repo as (1) the owner and (2) a contributor. There may be other ways of updating a repo, so this article presents one way that works.

The beginning point for this article assumes that the repo has already been created on Github with a public repository url in the form https://github.com/owner/repo.git and that you have Github installed on your pc and can run commands with >git . All of the code commands are executed in Windows 10 command prompt which is run using "cmd". The repo for this example is https://github.com/footprintzero/foodwall


Repo owner

  1. From command prompt update your git instance settings. You should be in the root directory one level above your repo. You only need to do this when you change repos or accounts ~root> git init ~root> git config - -global user.name footprintzero

  2. Clone the repo onto your pc. This step should be skipped if you already have a local repo, otherwise you will see an exception mentioning that the folder already exists. ~root> git clone https://github.com/footprintzero/foodwall.git

  3. Move into the local repo directory on your pc ~root>cd foodwall

  4. Connect your git instance to the repo ~root\foodwall> git remote rm origin ~root\foodwall> git remote add origin https://github.com/footprintzero/foodwall.git

  5. Sync your local copy to the master repo ~root\foodwall> git pull master master

  6. Create a branch ~root\foodwall> git checkout -b owner_update

  7. Apply edits to your local copy. Once you are ready, move to step 8

  8. Push a commit request to your Github account ~root\foodwall> git add - -all ~root\foodwall> git commit -m "comments for owner update" ~root\foodwall> git push origin owner_update

  9. You should be promoted to authorize by supplying your username and password

  10. Login to your Github account and add commentary about your branch, create the pull request using the Github web browser interface.

  11. As the owner - review the pull request and apply the changes via Merge.


Contributor to someone else's Repo

As a contributor, the steps of creating a branch, editing and pushing the commit request are identical to those as the owner. The difference is that instead of working on the master, you are working on a fork of the master that resides in your contributor Github account. This section will cover the differences between the owner and contributor, so read first the owner steps above as they will not be repeated in detail below.

  1. Create a fork from the master. Login to your Github account and navitate to the master repo url https://github.com/footprintzero/foodwall . Next click "Fork" in the top right corner. Now you should have a new repo under your account. This is the fork. You only need to create a fork once and you can continue to re-use this fork for all subsequent updates. https://github.com/taylorhickem/foodwall

  2. Update your github instance. Same as the owner, only in this case you use your contributor account. ~root> git config - -global user.name taylorhickem

  3. Clone your fork and move into the directory ~root> git clone https://github.com/taylorhickem/foodwall.git ~root> cd foodwall

  4. Connect your git instance and sync to the master repo using upstream command ~root\foodwall> git remote add upstream https://github.com/footprintzero/foodwall.git ~root\foodwall> git pull upstream master

  5. The remaining steps are the same as owner for checking out a branch, editing and pushing a commit request. When prompted for credentials enter your contributor account username and password. Login to Github to review and submit your pull request, where you can add more detail to your pull request by summarizing the changes with HTML and file attachments. You have control of applying changes to your fork, however the repo owner retains control of merges to the master.

Using personal access token (PAT)

In July 2020, Github announced that they would no longer support login with username and password after 31 Aug 2021 and would require personal access tokens (PAT). The steps for creating and using a PAT are adapted from this article in the github documentation. Create a personal access token

  1. verify your email address (if you haven't done so already)

  2. login to your github account

  3. navigate to Settings --> Developer Settings --> Personal access tokens

  4. generate a new token

  5. customize your token. Give it a name, expiration and access rights

  6. take note of the token key (string). use it like a password

Login using a personal access token

  1. use your PAT as a substitute for password when logging in ~root> git clone https://github.com/taylorhickem/foodwall.git Username: footprintzero Password: personal_access_token

Updating your credentials


Windows Credentials Manager

  1. Control Panel -> Credential Manager -> Generic Credentials -> Windows Credentials

  2. Scroll to git:https://github.com and edit username and password. You can use either personal password or PAT

PyCharm project main article: change git user in IntelliJ IDEA

  1. Navigate to the project root directory

  2. Navigate into hidden directory called ".git"

  3. search for "config" file and add the below code.

[user]
      name = username
      email = username@domain.com
79 views0 comments
bottom of page