Skip to content

Instantly share code, notes, and snippets.

@ccannon94
Last active February 18, 2020 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ccannon94/2d69b4c988f1298ebeb1a0873c7685f9 to your computer and use it in GitHub Desktop.
Save ccannon94/2d69b4c988f1298ebeb1a0873c7685f9 to your computer and use it in GitHub Desktop.
How to Fork your Repositories

Forking a Repository

What is a "fork"?

  • Just like branches allow members of a development team to work on different features independently of each other, forks allow entirely different teams or individuals to work on projects in their own "silo", so to speak.
  • Imagine you find a great open source app that you'd like to use, but you really need it to do one thing differently. The easiest way to accomplish this is through a fork! You can fork the repository, make the change you need to make in the code, and build from your fork of the repository rather than the original developer's.
  • If you think your change can benefit the community as a whole, you can make a pull request to merge your fork back into the original project, just like branches!

Why use forks?

  • It may seem like forks are just more complicated branches, so why use them?
  • Branches work just fine for any developer who has push access to a repository. Push access means the ability to push commits to the repository. You are all assigned push access to your repositories for assignments. Our class organization maintains ownership of the code, but you can push any code you want to any branch except protected branches, like master.
  • However, it is best to reserve push access, even on a public open source project, to trusted developers only. This prevents cluttering of the main public repository and keeps your development branches clean and safe.
  • This is why GitHub offers forks! Anyone who would like to modify, contribute to, or make their own version of your code has a totally safe, separate area in which to do so, and it can easily be merged back into the original project.

How to use forks

Now that we know why we will use forks, let's learn how we will use them!

  1. Navigate to a repository you do not own. Try going to our class organization, which will show you all of the repositories you've worked on in this class. Remember that you do not own these, so you can and should fork them! NCAndTCS GitHub Page
  2. From the repository home screen, locate the Fork button as shown below. Repository View with Fork Button Highlighted
  3. There you have it! Notice that the repository is now under your name. You have complete control of the fork. If this fork is for contribution to an open source project, you can select Create Pull Request after committing and select the source repository as the base.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment