• Taylor Hickem

Contributing to a Github repository

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.

13 views0 comments