Subscribe to our Premium Bi-Monthly WPTakeaway Newsletter by WPCouple! What is WPTakeaway?

Pull requests are the way of contributing or collaborating on a project on GitHub. Let’s say you want to contribute to a repository on GitHub, maybe fix a bug or a typo. Since you don’t own the repository, you can’t directly make the changes. So, what you do is, you simply make a copy/forkΒ of the repository, make changes, and create a pull request.

create a pull request

When you create a pull request, the owner of the original repository is notified that you have created a pull request and proposed some changes. The repository owner can review the changes, merge them, ask for a revision, or even discard them. This is how pull requests work on GitHub.

πŸ”₯Β FUN FACT

Ever wondered why it is called pull request, not push request? The reason is that you ask the repository owner to pull changes from your copy.

⚑ Steps to Create A Pull Request

According to our understanding of how pull request works, there are three basic steps to create a pull request:

  1. πŸŽ— Fork the repository
  2. 🎬 Make changes in copy
  3. 🎯 Create a pull request

β†’ Fork the Repository

To fork a repository, open the repository and click on the Fork button at the top left corner. For example, I am forking thisΒ Hacktoberfest repository by Ahmad Awais.

Forking a repository on git hub

β†’ Make Changes in the Copy

Next step is to make the changes in the copy i.e fix the typo, bug, or whatever you want to contribute. You can either do it directly on GitHub – I will be doing in this guide – or you can clone the repo and push changes from your machine.

At the time of writing this piece, I just noticed that there’s a colon missing in front of a heading in this repo. So, I am going to propose a fix for it.

Making changes in the repo

Since it’s a minor fix, I can simply go ahead and edit the file on GitHub. However,Β I do notΒ suggest to edit files on GitHub for major changes in the repo. To do so, open the file in your copy of the repo and click on theΒ EditΒ button at top right corner.

Editing a file on GitHub repo

Clicking on the icon will open the file for editing. Make the changes you want to do and scroll down the screen. At the bottom, you’ll see a section namedΒ Commit changes. In this section, you provide the description and title of the proposed changes. Fill in the details and click onΒ Commit Changes button.

Adding details of the commit

Once you have clicked the Commit changes button, your changes will be saved in the file. Now, your copy of the repo is different from the original repository and you can create a pull request.

⚑ Tips on Writing a Good Git Message by Ahmad Awais

  • Every Pull Request must have a title.
  • Every Pull Request must have a description.
  • Write the title and description of what you have done in the imperative mode, that is as if you were ordering someone.
  • βœ…Β DO: Start the line with “FIX“, “NEW“, “IMPROVE“.
  • ❌ DON’T: Start with “Fixed“, “Added“, “Adding“, “Improved“.
  • 🎯 Read β†’ How to Write a Git Commit Message
  • Β Don’t end the summary line with a period – it’s a title and titles don’t end with a period.
  • Β Have fun. πŸŽ‰

β†’ Create Pull Request

Once you have made changes to the copy of a repository, the next step is to create a pull request. To do so, open the copy of a repository and click on the Pull Request option.

Creating pull request

It will show you a detailed comparison between the original repository and your copy. Modified files are displayed side by side where you can review your changes before you finally create pull request. Remember:

βœ… Green lines show the modified or newly added part of the file.

β›” Red lines show the removed part of the file.

After reviewing the changes, click on theΒ Create Pull Request button at the top. It will open a new window asking you details about the pull request. By default, it picks up the commit message details.

Again, use the tips shared above to write a proper pull request message. Finally, click onΒ Open pull requestΒ button to create a pull request.

Opening a new pull request on GitHub

πŸ”± Sometimes the repository owner adds a code of conduct and contributing guidelines to create a pull request. In case, if there is any guideline by repository maintainer, make sure you follow that. It helps them quickly understand the pull request and review it.

For example, in the above pull request description, I answered a question in the description i.e What does a pull request do? – IMPROVE. It was a part of contributing guideline to easily understand the proposed change. That was all for it! If you have any questions feel free to ask in the comments below.

Peace. ✌

πŸ™Œ

SUBSCRIBE TO WORDPRESS TAKEAWAY!

A Premium Bi-Monthly Newsletter by WPCouple! What is WPTakeaway?

There are currently no comments.

πŸ™Œ You must have something to say here...