Note that this site is in currently in version 1.0.0-alpha.   Some functionality may be limited.

9. Cloning and Forking

GitHub was built for sharing and collaborating on projects. A key advantage of the platform is that you can find lots of bits of software that do many different things—such as code for plugins for WordPress or Leaflet. Increasingly, you might find syllabi or open writing projects. If a project is public, you can save a copy of it to your local machine, work on it, save your admendations and share it on your own GitHub account. Like we’ve already mentioned, GitHub usefully helps track attribution along the way. Cloning and forking are the basic functions of this capability. Each are first explained below, and followed by an example and activity to further explain.


Cloning a repository means making a copy of a repository on GitHub, to download and work on locally—on your local machine. By entering the following code into your terminal, you can clone any public directory on GitHub:

$ git clone <repository-url>

When you clone a repository from GitHub, the folder that shows up on your local machine comes built-in with a few things. First, Git is already present, so you don’t need to initialize the folder. Also, the connection between your local copy and the online repository is already made, so git push origin main will work (no -u flag needed).

For practice, let’s clone the repository for this workshop about Git and GitHub, which lives on GitHub.

First, let’s navigate back to your Desktop folder.

$ cd ~/Desktop

Remember that the ~ refers to your home directory. Now let’s find the URL we need to clone the lesson.

First, visit this workshop’s page on GitHub.

On the main page, there should be a green Code button on the right side:

Image pointing out where the clone or download button is on GitHub

Click the green button and you will see a box with highlighted text under a heading that says Clone with HTTPS. If you instead see Cloning with SSH, click the small link that says Use HTTPS.

Now copy out the text in the box:

Image showing where the text you need to copy is located

Now that you have the text copied, go back to your terminal. Remember, you should be on the Desktop. (Hint: Use pwd to find out what your current working directory is.)

Once you are in the Desktop, type:

$ git clone <copied-url>

If the command is successful, the full Git and GitHub workshop’s text will be replicated on your local machine. To navigate into the folder, its name is git and you can use the cd command to access it:

$ cd git

Use the ls command to take a look at the various files in the lesson folder.

Cloning can be especially useful when you’re joining a group project that is hosted on GitHub, and you want your changes to eventually be pushed and shared with that same repository.

But maybe that is not possible or ideal. Maybe you don’t want to contribute your changes to someone else’s repository. Maybe you want to make a derivative of their folder for yourself, on your GitHub account, and make changes there.

Forking is the step you could take to do this.


Forking a repository means making a copy of someone else’s repository on GitHub, and saving it to your account on GitHub. This function happens within GitHub, and has nothing to do with what is happening on your local machine. Note that forking will not automatically make the repository appear as a folder on your computer; that’s the role of cloning.

In order to “fork” the git repository into your own GitHub account, follow these steps.

First, go to the repository for this workshop on GitHub. Note the Fork button in the upper right hand corner. By clicking that button, you can copy, or fork, this repository to your account.

Image showing where the button to fork a repo is located

Doing so would also adjust the attribution information in the upper left hand corner. Your username would replace DHRI-Curriculum, showing that you are looking at a copy of the repository on your account now. Additionally, it will reference the origin account, in this case, DHRI-Curriculum below after forked from, since this was the origin point of your fork.

Image showing the changes in attribution that happen when a repo is forked

Your local machine would come into play when you want to clone that repository so you can work on it locally. This also means that when you push those changes to GitHub, you would be pushing them to a forked repository associated with your own account.

You might use this method if you were going to teach your own Git & GitHub workshop. You could use our repository as a base for getting started, and add more examples or change some language, clarify something further, or create a connection to another workshop you are giving, etc. This allows us to continue to use the workshop as we have it as well. Also, maybe at a later time, we want to merge some of your changes with ours. We can do that too by revisiting your version history.

Challenges for lesson 9

Assignment: Challenge

  1. Fork and clone the repository for this workshop on GitHub. Note not only what you are doing, but also where you are working when completing these two different tasks.
  2. Make changes to the files on your local machine. Remember to save them!
  3. Use the 3-step process of stage, commit and push to return the amended files to the repository on GitHub.

Rather than write out the solution here, I want to encourage you to go back through the lessons as needed.

You’ll know you’ve completed step one when the project folder (called git) shows up on your local machine.

After you’ve made and saved the changes, you’ll know you’ve completed step three when your changes appear in the project folder on your GitHub account.


Try again!

Which best describes cloning?

(Select one of the following)

Try again!

Which best describes forking?

(Select one of the following)

Terms Used in Lesson

Can you define the terms below? Hover over each of them to read a preview of the definitions.


Cloning a repository means making a copy of a repository on GitHub, to download and work on locally—on your local machine. Cloning can be especially useful when you’re joining a group project that is hosted …

See term page


Forking is a proper function of the GitHub platform. It supports collaboration by allowing you to copy someone else’s repository to your own account on GitHub while maintaining a trail of attribution and derivation. Once …

See term page


Git uses the term repository to refer to a folder that is being tracked. Colloquially, this term is often shortened to “repo”.

See term page

Workshop overall progress