Git & GitHub
/Intermediate
Forking Repositories
Definition
A fork is a complete, personal copy of someone else's repository that lives on your account. Forks allow you to freely make changes to a project without affecting the original upstream repository.
Explain Like I'm New
The 'Copy and Paste' button of Open Source. If you want to fix a bug in the React framework, Facebook will not give you permission to edit their files. Instead, you click 'Fork'. GitHub instantly creates a perfect clone of React on YOUR profile. You fix the bug on your copy, and then politely ask Facebook to copy your fix over to theirs (a Pull Request).
Real World Example
Creating your own custom version of an open-source video game emulator, adding your own features, and releasing it as a totally independent project.
Common Use Cases
- •Open Source contributing
- •Creating independent spin-off projects
Terminal Output
bash / terminal
/*
The Standard Open Source Workflow:
1. Click 'Fork' on the target GitHub repository.
(This copies it from facebook/react to your-name/react)
2. Clone YOUR fork to your computer:
$ git clone https://github.com/your-name/react.git
3. Make a branch, fix the bug, commit, and push:
$ git push origin bug-fix
4. Go to GitHub and click 'Create Pull Request' to send
the code back to the original author!
*/
Interview Questions
basic
- Is 'forking' a native Git command?
intermediate
- If the original repository updates, does your fork update automatically?