- Fork a repo
- Clone a repo
- Push to different remote repos
##Forking a GitHub Repository Forking a GitHub repository is just a way to create your own copy of it. We do this all the time while using Learn. Every time you fork a lab, GitHub creates a copy that you can use as a sandbox to play around, all while maintaining a canonical repo where the original lab remains intact. In other words, forking creates another remote that allows you to work in your own world without messing with the core learn-co-students content.
You can fork any repo by clicking the "Fork" button at the top right of any GitHub repository. Learn also makes it easy by allowing you to click the "OPEN" button at the top of any lab (if you use the Learn IDE) or to simply type learn open
in your terminal (if you use a local development environment). It's also worthwhile to note that you can go to your fork of a given lab by changing the "learn-co-students" bit of the GitHub URL to your GitHub username. For example:
https://github.com/learn-co-students/first-lab-001-prework-web
Change "learn-co-students" to your username:
https://github.com/your-username-here/first-lab-001-prework-web
More on forking in the GitHub docs.
##Cloning Now we want to get our forked copy of the repository on our local machine. This is where cloning is useful. To do this:
-
Navigate to your forked repo on GitHub.
-
Make sure you select
SSH
as your URL type. -
Click the "Copy to clipboard" button (highlighted below). This will copy the URL for us to use when we clone.
-
In the terminal, run the
git clone
command. It takes the URL we just copied as an argument:git clone your-copied-github-url
This will create a local copy of our forked GitHub repository.
View Forks and Clones on Learn.co and start learning to code for free.