DEV Community

Cover image for Forking - A guide for contributing to opensource
Sudharsan G S
Sudharsan G S

Posted on

Forking - A guide for contributing to opensource

What is a fork?

A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.

How to fork?

It's so simple that it happens on a click of a button.
Alt Text
The fork button will be available on the top right corner of any Github repository.

Now you can clone the forked project to your machine locally.
Alt Text

You can clone using SSH or HTTPS.

git clone git@github.com:sudharsangs/styled-components.git
Enter fullscreen mode Exit fullscreen mode

Now that you have cloned the repository. You have to make sure you are syncing with the original one. Syncing means if the maintainer of the repository updates the code you should be able to get that in your forked repository.

cd styled-components
git remote add upstream https://github.com/styled-components/styled-components.git
Enter fullscreen mode Exit fullscreen mode

Now you have set the upstream of your cloned repository to the original one.

To get the updated code you should execute the following commands.

git fetch upstream
git merge master upstream/master
Enter fullscreen mode Exit fullscreen mode

This is how you fork and contribute to any repositories on Github.

Happy Forking

gif

Top comments (0)