In Git, a pull request is an event involving a project contributor who is requesting that a repository maintainer review the code they wish to merge into a project’s repo. This feature is not built into Git itself, but is a function controlled by the remote repository hosting service, such as GitHub.
GitTip: More of a visual learner? Check out our short, intermediate Git tutorial video on what is a pull request in Git.
How to Create a GitHub Pull Request
Something foundational to remember about Git pull requests is that they are dependent on branches. This means that you will need to have a branch containing changes you wish to merge before you get started creating a pull request.
Once you have created a local Git branch with the changes you want to merge into a project’s main repository, you will want to Git push the branch to your remote repository.
We’re going to go over the process of creating and submitting a GitHub pull request using the legendary cross-platform GitKraken Git GUI, before going over the process in the CLI.
“GitKraken has a nice UI for pull requests and tells you which branch you’re on and which branch the PR is referring to (which is the thing I always get wrong).” – @spaghettidba
Do you have any recurring mistakes GitKraken can help you overcome?
How do you create a GitHub pull request using GitKraken?
The GitHub integration in GitKraken makes it easy to create a GitHub pull request.
Get started by clicking the green + button from the PULL REQUESTS pane in the left panel.
Next, you will drag-and-drop the branch you wish to merge from onto the branch you wish to merge to directly from the central graph.
Learn more about using drag-and-drop to push in GitKraken.
The drag-and-drop functionality in GitKraken makes pushing and pulling, and creating pull requests, visually intuitive while saving you precious coding time.
GitHub Pull Request Template
If this is a new local branch, GitKraken will ask what remote branch you want to push your changes to. At this point, you will also have the opportunity to complete the fields of your GitHub pull request template including title, description, reviewers, assignees, and labels before clicking the Create Pull Request button.
GitHub Pull Request Draft
You can also see that there is the option to create a GitHub pull request draft by clicking the box next to Submit as draft.
Additionally, you can click the Continue editing on GitHub link if you prefer to edit your GitHub pull request directly on the hosting service.
Review GitHub Pull Requests
After your GitHub pull request has been created in GitKraken, you will be able to view the PR from the PULL REQUESTS pane. Clicking on an individual PR will open GitKraken’s interactive pull request management view for GitHub.
From here, you can review your GitHub pull request, make additional edits to your GitHub pull request, including adding comments and associating a build status and milestone. You can even merge and approve GitHub pull requests directly from this view in GitKraken, and checkout and test pull request branches. 🤯
“The new GitHub Pull Request view is fantastic! 👏 Loads faster than GitHub! 🔥” – Jake, GitKraken User
How do you create a GitHub pull request in the command line?
Now, if you’re working in the command line and have a local branch with changes you wish to push to a remote, you will start by performing a Git push with the following command:
git push branch
Alternatively, if your branch does not yet exist on the remote repository, you can set the upstream of the branch in Git.
git push --set-upstream <branch-name> <branch-name>
Now that your local branch has been pushed, you can start your GitHub pull request. To begin this process, you will navigate to the main page of your GitHub repository and select the branch with your changes.
Next, you will hit Contribute → Open pull request.
You can also navigate to the GitHub pull requests section and click New pull request.
Now, at this point, you will want to check for two things:
- The “base” branch should be the branch you wish to merge to
- The “compare” branch is the branch you want to merge from
Now, you are ready to add your GitHub pull request title and description before clicking the Create pull request button.
Pro Tip: If you aren’t quite ready to submit your PR, you can create a GitHub pull request draft by selecting the Create draft pull request option from the drop-down menu.
Now, wasn’t that process much easier using the GitKraken Git GUI?