Reputation: 24315
How do I create and/or send a pull request to another repository hosted on GitHub?
Upvotes: 302
Views: 157615
Reputation: 367
The best way in 2023 is clearly to use the GitHub VS Code extension, and you don't have to think about this anymore.
It leads you right through the steps from cloning your fork to creating the pull request.
Upvotes: -1
Reputation: 1329492
(In addition to the official "GitHub Help 'Using pull requests' page",
see also "Forking vs. Branching in GitHub", "What is the difference between origin and upstream in GitHub")
Assuming that you have first forked a repo, here is what you should do in that fork that you own:
master
, where you could be tempted to accumulate and mix several modifications at once.origin/master
(making sure your patch is still working) will update the pull request automagically (no need to click on anything)git remote prune origin
). The GitHub GUI will propose for you to delete your branch in your pull-request page.Note: to write the Pull-Request itself, see "How to write the perfect pull request" (January 2015, GitHub)
March 2016: New PR merge button option: see "Github squash commits from web interface on pull request after review comments?".
The maintainer of the repo can choose to merge --squash
those PR commits.
Regarding the last point, since April, 10th 2013, "Redesigned merge button", the branch is deleted for you:
Deleting branches after you merge has also been simplified.
Instead of confirming the delete with an extra step, we immediately remove the branch when you delete it and provide a convenient link to restore the branch in the event you need it again.
That confirms the best practice of deleting the branch after merging a pull request.
pull request isn't an official "git" term.
Git uses the request-pull
(!) command to build a request for merging:
It "summarizes the changes between two commits to the standard output, and includes the given URL in the generated summary."
Github launches its own version on day one (February 2008), but redesigned that feature in May 2010, stating that:
Pull Request = Compare View + Issues + Commit comments
<humour>
That (pull request) isn't even defined properly by GitHub!
Fortunately, a true business news organization would know, and there is an e-note in order to replace pull-replace by 'e-note':
So if your reposotory needs a e-note... ask Fox Business. They are in the know.
</humour>
Upvotes: 246
Reputation: 1375
The Simplest GitHub Pull Request is from the web interface without using git.
Click the pencil icon,
search for text near the location, make any edits you want then preview them to confirm. Give the proposed change a description up to 50 characters and optionally an extended description then click the Propose file Change button.
If you're reading this you won't have write access to the repository (project folders) so GitHub will create a copy of the repository (actually a branch) in your account. Click the Create pull request button.
Upvotes: 0
Reputation: 6561
I wrote a bash program that does all the work of setting up a PR branch for you. It performs forking if needed, syncing with the upstream, setting up upstream remote, etc. and you just need to commit your modifications, push and submit a PR.
Here is how you run it:
github-make-pr-branch ssh your-github-username orig_repo_user orig_repo_name new-feature
You will find the program here and its repository also includes a step-by-step guide to performing the same process manually if you'd like to understand how it works, and also extra information on how to keep your feature branch up-to-date with the upstream master and other useful tidbits.
Upvotes: 2
Reputation: 24315
To learn how to make a pull request I just followed two separate help pages on Github (linked below as bullet points). The following command line commands are for Part 1. Part 2, the actual pull request, is done entirely on Github's website.
$ git clone https://github.com/tim-peterson/dwolla-php.git
$ cd dwolla-php
$ git remote add upstream https://github.com/Dwolla/dwolla-php.git
$ git fetch upstream
// make your changes to this newly cloned, local repo
$ git add .
$ git commit -m '1st commit to dwolla'
$ git push origin master
Part 1: fork someone's repo: https://help.github.com/articles/fork-a-repo
git clone->cd dwolla-php->git remote->git fetch
sequence above to clone your fork somewhere in your computer (i.e., "copy/paste" it to, in this case: third_party TimPeterson$
) and sync it with the master repo (Dwolla/dwolla-php)git add->git commit->git push
sequence above to push your changes to the remote repo, i.e., your fork on Github (tim-peterson/dwolla-php)Part 2: make pull-request: https://help.github.com/articles/using-pull-requests
Upvotes: 210
Reputation: 28229
I've started a project to help people making their first GitHub pull request. You can do the hands-on tutorial to make your first PR here
The workflow is simple as
git clone <clone url you copied earlier>
git checkout -b branch-name
git commit
git push origin branch-name
Compare and pull request
buttonUpvotes: 17
Reputation: 13057
For those of us who have a github.com account, but only get a nasty error message when we type "git" into the command-line, here's how to do it all in your browser :)
Upvotes: 17
Reputation: 1601
In order to make a pull request you need to do the following steps:
It took me a while to figure this, hope this will help someone.
Upvotes: 70
Reputation: 657
I followed tim peterson's instructions but I created a local branch for my changes. However, after pushing I was not seeing the new branch in GitHub. The solution was to add -u to the push command:
git push -u origin <branch>
Upvotes: 4