Fork A Repo

If you’ve found yourself on this page, we’re assuming you’re brand new to Git and GitHub. This guide will walk you through the basics and explain a little bit about how everything works along the way.

First: Fork A Repo

At some point you may find yourself wanting to contribute to someone else’s project, or would like to use someone’s project as the starting point for your own. This is known as “forking.” For this tutorial, we’ll be using the Spoon-Knife project.

  1. Fork the “Spoon-Knife ” repo

    To fork this project, click the “Fork” button.

    Click “Fork”

Next: Set Up Your Local Repo

You’ve successfully forked the Spoon-Knife repo, but so far it only exists on GitHub. To be able to work on the project, you will need to clone it to your local machine.

  1. Clone the “Spoon-Knife” project

    Run the following code:

    $ git clone git@github.com:username/Spoon-Knife.gitClones your copy of the repo into the current directory in terminal
    
  2. Configure remotes

    When a repo is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repo it was forked from. To keep track of the original repo, you need to add another remote named upstream:

    More about remotes

    A remote is a repo stored on another computer, in this case on GitHub’s server. It is standard practice (and also the default in some cases) to give the name origin to the remote that points to your main offsite repo (for example, your GitHub repo).

    Git supports multiple remotes. This is commonly used when forking a repo.

    $ cd Spoon-KnifeChanges the active directory in the prompt to the newly cloned "Spoon-Knife" directory
    $ git remote add upstream git://github.com/octocat/Spoon-Knife.gitAssigns the original repo to a remote called "upstream"
    $ git fetch upstreamPulls in changes not present in your local repository, without modifying your files
    

Then: More Things You Can Do

You’ve successfully forked a repo, but get a load of these other cool things you can do:

Lastly: Celebrate

You have now forked a repo. What do you want to do next?

  1. Set Up Git
  2. Create A Repository
  3. Fork A Repository
  4. Be Social