News

How to Open a Pull Request on GitHub

A pull request (PR) is a GitHub feature that allows you to propose changes to a repository to which you do not have write access. The repository maintainers can review these changes and, if they choose, merge them into the original repository.

Opening pull requests on GitHub is crucial in contributing to open-source projects and collaborating with other developers. Learn how to create and open a pull request on GitHub in just a few easy steps.

Step 1: Forking the Repository

Forking a repository on the GitHub platform creates a copy—otherwise known as a “fork”—of that repository, under your account. Forking a repository allows you to make changes to the code without affecting the original repository.

To fork a repository, navigate to its main page and click the fork button in the top right corner:

Highlighted GitHub fork button

Fill in the repository name (fork) and an optional description and click Create fork:

A GitHub create new fork form

Now you have created a copy of the original repository. This new repository has a connection with the original so that any changes you make to the code can be easily compared and merged back into it.

Step 2: Making Changes to the Code

After you have forked the repository, you might need to clone it to your local machine, depending on the amount and nature of changes you wish to propose. If you’re making very simple changes that you don’t need to test, you can do so online using the GitHub web-based editor.

To clone a repository to your local machine using Git, run this terminal command:

git clone 

Replace with your repository’s URL—you can find this on GitHub. This command will clone the repository to your local machine, where you can freely experiment and make changes to the code.

You should keep your changes small and focused, as large pull requests can be challenging to review and merge. Try to keep your changes specific to one problem or feature, to make it easier for the maintainers to review and accept them.

After making your desired changes locally, commit them and push them to your GitHub fork using Git.

Step 3: Opening a Pull Request

After you have committed your changes to GitHub, you should see a prompt alerting you that your branch is a number of “commits” ahead of the repository you forked it from, for example:

A GitHub message showing a project ahead of its upstream repository.

Click the Contribute dropdown. Clicking this button will prompt you to open a pull request. Then, click the Open pull request button:

GitHub repository main page with the open pull request button highlighted

Some repositories have specific contribution guidelines, which you can typically find in a CONTRIBUTING.md file, that you need to follow. Make sure to read and follow these guidelines before you submit a pull request.

Next, fill in the required fields and click on the Create pull request button:

A GitHub pull request form with its Create button highlighted.

Your commit message should be clear and concise, describing the changes you made and the reasoning behind them. This will help maintainers understand your changes and make it easier for them to review the code.

Once you’ve created your pull, you’ll need to wait for the project’s maintainers to review and merge it or close it. The maintainers may have suggestions or feedback on your pull request. Be open to changes and willing to make revisions if they ask you to.

The Importance of Pull Requests

Pull requests facilitate collaboration between developers by enabling them to propose changes, provide feedback, and review code. This helps to foster a sense of community and collaboration within a project, leading to more contributions and faster development.

Furthermore, pull requests organize the project’s history and versioning by allowing maintainers to keep track of the different versions of the code and the changes made to each version.

Muhabarishaji

🧪 |Medical Laboratory Scientist 🥇 | Mindset over Everything. 
 🤝 | Let's Grow Together.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Update Contents