Fork a project from GitHub.com and clone it locally.

Forks

So far you have made a project locally and pushed it to GitHub, but that's only half the fun! The other half is working with other people and other projects.

When you fork a repository, you're creating a copy of it on your GitHub account. Your forked copy begins its life as a remote repository—it exists just on your GitHub account, not on your computer. Forks are used for creating your own version of a project (this diversion from the original is like taking a fork in the road) or contributing back your changes (such as bug fixes or new features) to the original project.

To get a forked repository from your GitHub account onto your computer you clone it. This cloning action copies the remote repository onto your computer so that you can work on it locally.

A diagram showing a repository from GitHub copied onto your GitHub account and then copied onto your local computer from there.

Fork the Patchwork Repository

The project we'll work with is at github.com/jlord/patchwork. Go to that page and click the 'Fork' button at the top right. Once the forking animation is complete, you have a copy on your account. Copy your fork's HTTP URL from the address bar in your browser, this is the address of your fork on GitHub's servers.

Clone Your Fork Locally

Now, in terminal, you'll clone the repository onto your computer. It will automatically create a new folder for the repository so there is no need to create one yourself. But make sure you aren't cloning it inside of another Git repository folder!

So be sure you're not inside of the 'hello-world' directory from the previous challenges. To back out and leave this folder so that you can clone, follow these steps:

Back out of your 'hello-world' folder:
Tip: the two dots mean step out of a directory one level

cd ..

Now that you're no longer in another Git repository, clone your fork:

git clone <URLFROMGITHUB>

Go into the folder it created for your local copy of the fork (in this case, named 'patchwork').

cd patchwork

Now you've got a copy of the repository on your computer and it is automatically connected to the remote repository (your forked copy) on your GitHub account. Type git remote -v to see that the address to the fork is already set up.

Connect to the Original Repository

What if the original repository you forked happens to change? You'll want to be able to pull in those changes too. So let's add another remote connection, this time to the original, github.com/jlord/patchwork, repository with its URL.

You can name this remote connection anything you want, but typically people use the name 'upstream'; let's use that for this.

git remote add upstream https://github.com/jlord/patchwork.git

To be sure you have the correct remotes set up, type git remote -v to list out the addresses you have stored. You should have an 'origin' remote with your fork's address and then an 'upstream' remote with the address to the original, with the URL noted above in this step.

{{{ verify_directory_button }}}