Search code examples
githubforkcloneterminology

Is cloning a project repo necessary to contribute to open source projects


I am a newbie to both StackOverflow and Opensource contributions, excuse me if I didn't put it correctly.

Here's the question :

I heard some contributors saying that you need to clone the open-source project's code to your machine to be able to contribute to that project, And at the same time they say that you fork it. I don't understand why we need to clone the code when we can fork it. Or both ways are fine?. Please help me with this.


Solution

  • On GitHub, a fork of a repository is a copy of it that the owner (in this case, you) controls. That lets you make changes to it by pushing additional branches containing code, and then, if you want, to make a pull request from your fork into the main project, requesting that the owner of the main project include the code from that branch. Both the fork and the original project are Git repositories that are stored on GitHub.

    Technically, you don't need to clone the code from GitHub if you've forked it since you can just edit the code in the GitHub web interface. However, practically, people prefer to write code on their own machines with their own editors and development environments. Usually you want to test the code you're writing as well, so you need it to be local to do that. So typically, you clone the repository to your system, create a branch, and make changes there. Then you can push the branch to your fork on GitHub, and then, if you want, create a pull request to the main repository.