Skip to main content

GitHub Fundamentals

How to Submit a Pull Request on GitHub

In this GitHub primer series, learn about submitting a pull request and contributing to open source projects.

So you want to contribute to Open Source and you've located a task or issue to work on.

That's good. The recommended workflow is to create a fork of the existing repository, make your changes and send a pull request.

GitHub issue

You've fixed the issue, tested your code but don't know how to send a pull request? Don't worry, this article is for you.

What is a Pull Request?

A Pull Request serves as a proposal to merge a set of changes from one branch into another. A fork can also be considered as another branch.

Collaborators can review and discuss the proposed changes before integrating them into the main codebase. Pull requests display the differences, or "diffs," between the content in the source branch and the target branch. - GitHub

Steps for Submitting a Pull Request

After creating a fork and committing your changes, you will find an option to create a Pull Request by clicking on the "contribute" button.

OPne pull request on GitHub

Comparing Changes

Upon clicking, you will be directed to a page comparing the commits and files of your current fork or branch, indicating whether it's "able to merge." "Able to merge" means there are no files with conflicts.

Compare changes in GitHUb pull request

If conflicts exist, preventing automatic merging, GitHub will notify you. You can still send your Pull Request, but it won't be merged until conflicts are resolved.

Conflict in GitHub pull request

Next, you'll be prompted to add your Pull Request title and description.

Pull request detail on GitHub

Your Pull Request will now appear in the Pull Requests Tab on the GitHub repository.

Pending pull request on GitHub

Merge Conflicts

Merge conflicts may arise when different branches modify the same line(s) of a file. It's crucial to pull others' code before making changes to have the history of their modifications.

In our example, while working on an issue to update a README file, the repository owner made changes to the same file.

As illustrated above, the current commit shows the current file data line-by-line. When making a Pull Request, you not only have the current data but also what it used to be.

Merge conflict example

In this illustration, line 2 was originally "cool project" and updated to "cool prect." The Pull Request however states that the line was "Cool prject" and then updated to "Cool project.

Git tracks not just file data but also commit data, preventing the addition of a commit with a modified file unless you first pull the changes that made it "cool prect" and then update it to "cool project."

Resolving Merge Conflicts

To resolve a merge conflict (well in this case) you will want to store your changes somewhere, rollback to the commit before you made any changes pull the new changes from their repository and then add your changes back by making another Pull Request, that way, your workflow looks something like this.

Resolving merge conflict

Notice how both repositories have the same number of commits and all have the same history.


After following the procedures in the article, I believe you will be able to easily create Pull Requests and deal with minor merge conflicts. The repo I used in this example is this. If you want to check that out, feel free to visit the repository.

Tutorial contributed by Judge-Paul Ogebe, a passionate front end developer and all-round tech enthusiast.
LHB Community