MakeUseOf logo

How to Open a Pull Request on GitHub

GitHub 3D Logo
Image Credit: Rubaitul Azad/ Unsplash -- no attribution needed
unsplash.com/photos/HLQDfaJUTVI

David is a skilled software developer and technical writer with extensive experience in building scalable backend infrastructure for web applications. He is well-versed in backend-focused software development and database administration, with a track record of delivering reliable software solutions.

As a technical writer with over 2 years of experience, David has written various in-depth articles on these topics, sharing his experience, knowledge, and insights with the wider community. He has a passion for keeping up-to-date with the latest trends and best practices in the field and enjoys sharing this knowledge with others.

Sign in to your MakeUseOf account

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]
Screenshot by david ekete --no attribution required

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

[画像:A GitHub create new fork form]
Screenshot by david ekete --no attribution required

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 <REPOSITORY_URL>

Replace <REPOSITORY_URL> 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:

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]
Screenshot by david ekete --no attrition required

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:

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.

AltStyle によって変換されたページ (->オリジナル) /