Skip to main content

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.

KBS Training

 

Consider that rewriting history on pull requests that were reviewed (or that in general have commenting about/referring code) could lead to confusion, since the history won't match anymore what comments were referring to. There is no easy solution: somebody will close the PR and refer it in a new one (to not rewrite history); my idea'd be to just backup the latest commit SHA that is being reset/rewritten and refer it in a comment on the PR, after the forced-push has been performed. IF prune doesn't remove that detached commit


Reply