Forking in Git and GitHub

Jonathan Peake

What is a Fork?

A fork is a new repository that shares code with the original “upstream” repository

  • Add to or modify repository hosted on someone else’s account

  • “Sees” changes from parent repo - allows syncing with parent

  • Can be for personal purposes - doesn’t have to be pushed to original repo!

Why fork?

  • Allows users to contribute to projects they are not directly a part of

  • Allows faster development and bug fixes

  • Outside contributors are what make a project truly “open source”

Several forking scenarios

  • Propose changes or fix bugs on a package or software

  • Add a feature to open source software

  • Use someone else’s repository as a basis for your own

The process of forking

  1. Create a fork from the parent repository
  2. If not making changes in GitHub, clone your forked repository to your local machine
  3. Make and commit your changes, making commits along the way if necessary
  4. If necessary, sync any changes made to the parent repository with your fork

The process of forking

  1. (Optional) Create a pull request to contribute your changes back to the parent repository
  1. Make any changes suggested/requested by the parent repository owner
  2. The repository owner will decide whether or not to merge your pull request

Things to keep in mind when forking

  • People (generally) want your engagement, suggestions, ideas, and contributions

    • Especially true for NMFS
  • Look for a contributing guide (commonly a CONTRIBUTING.md file) or wiki instructions for contributing

  • Be descriptive with your pull requests

  • Pull requests can be iterative conversations with the repo owner

Forking as a Worldview

Forks and forking are concepts that can be applied outside of the Git/GitHub realm

  • Slides

  • Documentation

  • Code/packages

  • Tutorials

  • Ideas

  • Movements

  • Many other examples