How to do a GitHub pull request

前端 未结 8 1945
一个人的身影
一个人的身影 2020-11-22 03:12

How do I create and/or send a pull request to another repository hosted on GitHub?

相关标签:
8条回答
  • 2020-11-22 03:45

    In order to make a pull request you need to do the following steps:

    1. Fork a repository (to which you want to make a pull request). Just click the fork button the the repository page and you will have a separate github repository preceded with your github username.
    2. Clone the repository to your local machine. The Github software that you installed on your local machine can do this for you. Click the clone button beside the repository name.
    3. Make local changes/commits to the files
    4. sync the changes
    5. go to your github forked repository and click the "Compare & Review" green button besides the branch button. (The button has icon - no text)
    6. A new page will open showing your changes and then click the pull request link, that will send the request to the original owner of the repository you forked.

    It took me a while to figure this, hope this will help someone.

    0 讨论(0)
  • 2020-11-22 03:45

    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 :)

    1. Same as Tim and Farhan wrote: Fork your own copy of the project:
    2. After a few seconds, you'll be redirected to your own forked copy of the project:
    3. Navigate to the file(s) you need to change and click "Edit this file" in the toolbar:
    4. After editing, write a few words describing the changes and then "Commit changes", just as well to the master branch (since this is only your own copy and not the "main" project).
    5. Repeat steps 3 and 4 for all files you need to edit, and then go back to the root of your copy of the project. There, click the green "Compare, review..." button:
    6. Finally, click "Create pull request" ..and then "Create pull request" again after you've double-checked your request's heading and description:
    0 讨论(0)
  • 2020-11-22 03:51

    (In addition of 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")

    Couple tips on pull-requests:

    Assuming that you have first forked a repo, here is what you should do in that fork that you own:

    • create a branch: isolate your modifications in a branch. Don't create a pull request from master, where you could be tempted to accumulate and mix several modifications at once.
    • rebase that branch: even if you already did a pull request from that branch, rebasing it on top of origin/master (making sure your patch is still working) will update the pull request automagically (no need to click on anything)
    • update that branch: if your pull request is rejected, you simply can add new commits, and/or redo your history completely: it will activate your existing pull request again.
    • "focus" that branch: i.e., make its topic "tight", don't modify thousands of class and the all app, only add or fix a well-defined feature, keeping the changes small.
    • delete that branch: once accepted, you can safely delete that branch on your fork (and 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 chose to merge --squash those PR commits.


    After a Pull Request

    Regarding the last point, since April, 10th 2013, "Redesigned merge button", the branch is deleted for you:

    new merge button

    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 vs. request-pull

    • 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 since day one (February 2008), but redesigned that feature in May 2010, stating that:

      Pull Request = Compare View + Issues + Commit comments
      

    e-notes for "reposotory" (sic)

    <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':

    https://pbs.twimg.com/media/BT_5S-TCcAA-EF2.jpg:large

    So if your reposotory needs a e-note... ask Fox Business. They are in the know.

    </humour>

    0 讨论(0)
  • 2020-11-22 03:58

    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

      1. click the 'fork' button on the repo you want to contribute to, in this case: Dwolla's PHP repo (Dwolla/dwolla-php)
      2. get the URL for your newly created fork, in this case: https://github.com/tim-peterson/dwolla-php.git (tim-peterson/dwolla-php)
      3. type the 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)
      4. make your changes to your local repo
      5. type the 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

      1. go to your fork's webpage on Github (https://github.com/tim-peterson/dwolla-php)
      2. click 'pull-request' button
      3. give pull-request a name, fill in details of what changes you made, click submit button.
      4. you're done!!
    0 讨论(0)
  • 2020-11-22 03:59

    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

    • Fork the repo in github
    • Get clone url by clicking on clone repo button
    • Go to terminal and run git clone <clone url you copied earlier>
    • Make a branch for changes you're makeing git checkout -b branch-name
    • Make necessary changes
    • Commit your changes git commit
    • Push your changes to your fork on GitHub git push origin branch-name
    • Go to your fork on GitHub to see a Compare and pull request button
    • Click on it and give necessary details
    0 讨论(0)
  • 2020-11-22 04:01

    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>
    
    0 讨论(0)
提交回复
热议问题