Reputation: 4409
Yesterday I submitted my first ever pull request to a project, this one in fact:
https://github.com/dotnet/corefx/pull/484
The feedback I got is that I need to clean it up because I put two commits into it when there should have been one. The first commit in the list was me getting the latest changes from the master and merging them into my fork, it should never have been part of the pull request I made but it seems I accidentally included it.
Given that I have never done one of these before how do I go about modifying it to remove the unnecessary commit? Reading around I'm not sure if I'm meant to rebase my branch, and if so I'm not sure how to continue.
Upvotes: 2
Views: 6163
Reputation: 4409
With the help of the project collaborators we managed to update the PR without doing a rebase, read below:
https://github.com/dotnet/corefx/pull/484#issuecomment-71073511
I don't fully understand it but it seemed to involve updating my fork and creating new branches to point HEAD
to the right place, then use git cherry-pick
to put the commit I wanted to the right place in my branch, then finally do a git push
; the PR was then automatically updated to the desired state.
Upvotes: 0
Reputation: 176552
You can use git rebase -i
to remove the commit. For instance, to remove the second last commit, use
$ git rebase -i HEAD~3
and simply remove the line for the commit you want to remove. Then force push.
$ git push origin <branchname> -f
Generally, it's not advisable to alter the history of a branch once published publicly, you should instead "revert" a commit.
However, if it was included by mistake, this is one possible option.
Upvotes: 2