DEV Community

loading...
Cover image for GitHub Workflow And Contribute To Open Source

GitHub Workflow And Contribute To Open Source

slimcoder profile image Slim Coder ・2 min read

In this article, we will discuss GitHub Workflow and how to contribute to open-source projects on GitHub.

Table Of Contents

Fork A Repository

First of all, we need to fork a repository. A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
Suppose if you want to contribute in freeocdecamp then you need to fork freecodecamp repository to contribute.
You can see a fork button on the top right corner.

Clone Forked

Now clone the forked repository by clicking clone or download button and open it in your favorite IDE to make changes.

Create A New Branch

Now our forked repository is cloned and we have opened it in our favorite IDE now we need to create a local branch with this command.

  git checkout -b branch_name //This will create a new branch locally
Enter fullscreen mode Exit fullscreen mode

Add Commits

Now we need to make changes and add commits locally.
The command is given below.

  git add . //This will add local changes
  git commit -m "commit_name" //This will add local changes and add the commit
Enter fullscreen mode Exit fullscreen mode

This command will add local commits.

Push To Forked Repository

Now we need to push our local branch and commit to the remote (forked) repository.
The command is given below.

  git push //This will push changes to remote branch
Enter fullscreen mode Exit fullscreen mode




Create A Pull Request

Now we have pushed local changes to the remote forked repository. Now we need to create a pull request which will be sent to the remote original repository.
After pushing the code we need create a new pull request by click on create pull request button and create a PR and select your branch to which you have made changes.

Code Review

Our PR is created successfully now we need to wait for our code to be review by the repository contributor/owner.

PR Merged

Our code is reviewed successfully by contributor/owner and now your PR is in a ready state to merge with the original repository.
The original repository owner will merge your PR. Hurray!
Congratulations you have successfully contributed to open source.

Discussion (0)

Forem Open with the Forem app