gitversion-controlgithubpull-request

Preferred Github workflow for updating a pull request after code review


I've submitted a change to an Open Source project on Github, and received code review comments from one of the core team members.

I would like to update the code taking into account the review comments, and re-submit it. What is the best workflow for doing this? From my limited knowledge of git/github, I could do any of the following:

  1. Update the code as a new commit, and add both the initial and updated commit to my pull request.

  2. Somehow (??) rollback the old commit from my repository, and create a single new commit containing everything, then raise a pull request for that?

  3. git commit has an amend feature, but I've heard that you shouldn't use it after you've pushed the commit outside of your local repository? In this case I have made the change on my local PC and pushed to my github branch of the project. Would this be OK to use 'amend'?

  4. Something else?

It seems like option 2/3 would be nice, as the open source project would only have one commit in their history which would implement everything, but I'm not sure how to do this.

Note: I don't know if this affects the answer or not, but I didn't make the changes in a separate branch, I just did a commit on top of master


Solution

  • Just add a new commit to the branch used in the pull request and push the branch to GitHub. The pull request will automatically be updated with the additional commit.

    #2 and #3 are unnecessary. If people want to see only where your branch was merged in (and not the additional commits), they can use git log --first-parent to only view the merge commit in the log.