Forking Projects
You can “fork” the project if you want to contribute to an existing project to which you do not have push access. GitHub can make a copy of the project that is fully yours when
you “fork” a project; it resides in your namespace, and you can push it.
By creating what is called a Pull Request, developers can fork a project, push it, and contribute their modifications back to the original repository.
1. Click on the fork to have a copy of the repository into your account.
2. Clone the repository onto your machine.
1 |
git clone git@github.com:<your-username>/<froked-repo>.git |
3. Add the original repository as a remote named upstream into the clone of your forked repository:
1 2 |
git remote add upstream git://github.com/<original-developer-username>/<repose-name>.git git fetch upstream |
You can see the remotes via:
1 |
git remote -v |
If you made a mistake or you want to change the upstream you can delete it with:
1 |
git remote rm upstream |
4. Pull the changes from original repo and update your fork to keep up with their changes:
1 |
git pull upstream master |
Difference between origin and upstream/ downstream on GitHub
Git is a distributed system, and being distributed largely means there is no inherent “upstream” or “downstream” in the system.
- upstream generally refers to the original repo that you have forked.
- origin is your fork: your own repo on GitHub, clone of the original repo of GitHub