Everything you need to know to master git, Part 10, git fork

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.

3. Add the original repository as a remote named upstream into the clone of your forked repository:

You can see the remotes via:

If you made a mistake or you want to change the upstream you can delete it with:

4. Pull the changes from original repo and update your fork to keep up with their changes:

Git fork workflow, credit: arthdatascience.org
Git fork workflow, credit: arthdatascience.org

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

 

Refs: [1], [2], [3]

0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x