Pull Request on Github
If you want to contribute to someone’s repo on Github, you can suggest your modification to the repo’s code by creating a Pull Request (PR). Before modifying the code, it is a recommended practice to fork the original code to your own Github account and subsequently make a new branch of the repo in which your will perform modification. To do modification to the repo, you can do it directly on the browser (on Github) if the modification is simple. If you are going to have a major modification, you typically will 1) clone the repo from your Github account to your local machine, 2) modify the code in your local machine, and 3) push the modified repo back to your Github repo.
The steps to make a Pull Request by modifying the repo directly on your own Github repo:
Step 1: Sign in to your Github account.
Step 2: While you are logged-in on Github, visit the repo you want to contribute and fork it to your own account. This is basically copying the repo to your own Github account.
Step 3: When you are to select between “Commit directly to the main branch” and “Create a new branch for this commit and start a pull request”, select the latter. Make sure to give a meaningful name to the new branch, for example: “fix/updated_file1”.
Step 4: Make modification to the code.
Step 5: Make Pull Request in your own Github repo. On the top side, make sure that the head repo is your current, new branch and the base repo is your main branch. Specify the PR by adding meaningful title and description of the PR.
Step 6: Merge in your own Github account.
Step 7: In the original repo (not in your Github acccount), create a Pull Request. On the top side, make sure that the head repo is the main branch from your own Github repo and the base is the main branch of the original repo. Add a meaningful title and description of the Pull Request.
The steps to make a Pull Request by modifying the repo on your local repo:
Steps 1 and 2: the same like in the above.
Step 3: Clone the repo from your remote repo. Use “git clone” to do this.
Step 4: In your local repo, create a new branch of the repo. You can use:
git checkout -b (new-branch-name)
Step 5: Make modification to the code.
Step 6: Bring the modified repo to the staging area using “git add” and subsequently make commit using “git commit -m “Meaningful comment””.
Step 7: Push the modified local repo back to the remote repo. You can use “git push -u origin (new-branch-name)”.
Step 8: Create Pull Request in your own Github repo. On the top side, make sure that the head repo is your current, new branch and the base repo is your main branch. Specify the PR by adding meaningful title and description of the PR.
Step 9: In the original repo (not on your Github acccount), create a Pull Request. On the top side, make sure that the head repo is the main branch from your own Github repo and the base is the main branch of the original repo. Add a meaningful title and description of the Pull Request.
After the Pull Request is created, the maintainer(s) of the original repo will review the Pull Request. If the maintainer(s) agrees, they will merge your modified branch with the original branch.
