Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

How to Create a Pull Request

This post will show you how to do Pull Requests to contribute to open-source projects such as Plotly. At the end of this tutorial, feel free to continue practicing by creating your own Pull Requests for the CharmingData/Practice-Pull-Request repository.

When you’re ready, check out our Plotly/Dash-labs repository to join the team and see how you can contribute to the projects being developed to make Dash even better.

Click to download the complete guide.
Click to watch the accompanying tutorial.

  1. Sign into your GitHub account (create an account first, if you don’t have one)
  2. Find the project you would like to contribute topractice-pull-request repository
  3. Identify what you would like to contribute
  4. Fork the project – click on “Fork”.

This will create a copy of the ‘practice-pull-request’ repository under your GitHub user account, as seen in the image below.

  1. Clone your forked project locally – click on the green Code arrow and click on the button to copy the https link.

Open your preferred Python IDE or command prompt (this example will be using PyCharm Terminal). Next, type ‘git clone’, followed by the https link you copied above. In this particular example, the script would be: git clone https://github.com/Coding-with-Adam/practice-pull-request.git
But your script would be slightly different because it would reflect your GitHub repository as opposed to Coding-with-Adam.

  1. Go into your cloned repository – type into terminal: cd practice-pull-request

  2. Create a new descriptive git branch – type into the terminal ‘git checkout -b’, followed by a name of a new branch you want. In this pull request example, we will suggest a darker Bootstrap theme used for one of the demo apps, so we’ll type: git checkout -b darker-theme
    (to learn more about branching, see Git Branching chapter on page 63 of this wonderful pdf: Git - Book)

  3. Create a new remote pointing to the upstream repository – This is necessary for syncing changes you make in your forked repository with the original repository. Type in the terminal ‘git remote add upstream’, followed by the original repository you created your fork from. In this example, it would be the original practice-pull-request repository. Therefore, the script to type should be: git remote add upstream https://github.com/charmingdata/practice-pull-request.git

  4. Contribute by making changes to the code – in this example we will open up the ‘demo-app.py’ file, which is one app example in the repository. This app uses the BOOTSTRAP theme, but we think that CYBORG is a much better fit. Therefore, change the script on line 11 from BOOTSTRAP to CYBORG.

  5. Verify the changes that you made – Ensure the changes you made to the code are correct by going to the terminal and typing: git diff --word-diff

  6. Commit your changes to the branch – type in the terminal ‘git commit -a -m’, followed by a brief message describing the commit. In this example, we changed to CYBORG, which is a darker app theme, so the script to type can be: git commit -a -m ‘make-darker-theme’
    You can see a summary of the commit below the script you typed in the terminal.

  7. Push the branch back up to your forked GitHub repository – Type in the terminal: ‘git push origin’, followed by the name of the branch you created in step 7. So, in this example, we type: git push origin darker-theme

  8. Initiate Pull Request process – go back online to your fork on GitHub. You will now see that you pushed a new topic branch up (darker-theme in this example). Next to it there is a wide green button. Click on it to check out your changes and to create a Pull Request to the original project.

  9. Create Pull Request – Creating a Pull Request allows the maintainers of the original repository (charmingdata/practice-pull-request in this example) to look over your contributions, start a conversation with you, make some changes, or decide to accept and merge. Make sure to write a good title and description because this helps the project maintainers understand what you’re trying to do and why your changes would make the original project better. Once you’re ready, click on the green button to create the Pull Request.

Final remarks:

Don’t wait for grandiose ideas or contributions. Even if you spot a small mistake in the code or if you think the ReadMe file can be improved, this can be a Pull Request. Get your feet wet and start practicing pull requests on this example repository.

5 Likes

I love this guide and GitHub - charmingdata/practice-pull-request: Fork this repository to practice Pull Requests repository so much! :heart:
I remember making my first pull request and wishing I had somewhere to practice before I submitted it. Git is confusing the first few times you use it but really gets easier with time and experience. And most of the time you can always revert any mistake :slightly_smiling_face:

4 Likes