Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify someone else's Github pull request?

Tags:

Someone created a pull request on my Github repo. It mostly looks good, but I had to make a few minor changes to get it to pass my continuous integration server.

Github's on-screen instructions to "review" the request were to run:

git checkout -b otheruser-fix_somebug git pull https://github.com/otheruser/myrepo.git fix_somebug 

I then made my changes, and committed locally. However, when I went to run git push, git informed me:

fatal: The current branch otheruser-fix_somebug has no upstream branch. To push the current branch and set the remote as upstream, use      git push --set-upstream origin otheruser-fix_somebug 

which I did, but my changes are not showing under the pull request, but instead under a copy of the branch otheruser-fix_somebug mirrored on my Github repo and unconnected to the pull request.

How should I have called git push to get the changes to appear on the pull request?

like image 615
Cerin Avatar asked May 17 '17 16:05

Cerin


People also ask

Can you edit a pull request GitHub?

Under your repository name, click Pull requests. In the "Pull Requests" list, click the pull request you'd like to modify. Next to the pull request's title, click Edit.

How do I make changes to an existing git pull request?

The current way to update a pull request is to click on the “Edit” button along the other pull request action buttons. This will bring you to the update pull request page where you can make changes to the title, description, reviewers and specify whether to close the branch after the pull request has been merged.

How do I update an existing pull request on GitHub?

Open GitHub, switch to local repositories, double click repository. Switch the branch(near top of window) to the branch that you created the pull request from(i.e. the branch on your fork side of the compare) Should see option to enter commit comment on right and commit changes to your local repo.


2 Answers

To my knowledge, you can only do this if they grant you permission. In the past this was only possible by them adding you as a contributor on their fork, however, in September 2016, GitHub added a feature for exactly this use case, allowing the person requesting the Pull Request to give permission to the maintainer(s) of the upstream repository simply by marking a checkbox.

You can make a comment on the Pull Request, telling them that their are some issues you'd like to fix before merging the Pull Request, and stating that you'd like them to give you permission to commit to their Pull Request branch by checking the "Allow edits from maintainers" checkbox on the Pull Request, and giving them a link to the GitHub Help page about the feature, so they can see exactly how to enable it. Once they've done so, you can push to the Pull Request branch of their repository directly.


Things you can do if they haven't/won't give you write access to their pull request branch:

  • Make comments on their Pull Request:

    1. Go to the Pull Request in your browser
    2. Scroll to the bottom of the "Conversation" (default) page
    3. Post comments describing the changes they need to make before you'll accept the PR.
  • Make comments on the code in their Pull Request:

    1. Go to the Pull Request in your browser
    2. Clicking the "Files changed" link at the top
    3. Hover over a line of code that should be changed
    4. Clicking the little blue "+" button that appears next to it
      (NB: these only appear on changed, and nearby lines)
    5. Post a comment and/or some code to fix what's there
    6. Repeat 3-5 as needed.
  • Accept it as is, then fix it in your own repository

    1. Merge their branch as if there was nothing wrong with it
    2. Make a new commit to your repository that fixes the issues (preferably mentioning the PR by issue id in your commit message so that GitHub can tell it's related and show it in the PR's Conversation page)
like image 147
3D1T0R Avatar answered Sep 27 '22 22:09

3D1T0R


What about checking out the branch from the Pull Request? Then you can do the commit there, and push to that branch directly.

git fetch git checkout fix_somebug 

add the commit with your changes

git push origin fix_somebug 
like image 28
mekoda Avatar answered Sep 27 '22 22:09

mekoda