Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing commit message in GitHub pull request

I have pushed some code for review and have been asked to change couple of my commit messages.

I tried doing git rebase -i HEAD~5 since it isn't my latest commit which needs to be changed.

Upon making changes, I now see that my branch has been diverged. What would have been the correct approach here?

I am not that confident, so would probably end up creating a new pull request all together. But, I would have liked to change in same pull request so that review comment history would have been retained.

like image 956
iDev Avatar asked May 11 '26 08:05

iDev


1 Answers

You don't need to create a new pull request. You can simply make the changes to your commit messages (or any other changes you'd like to make to your commits) and force-push them to the same branch on the remote. The pull request will be updated with the new commit contents. You can do that either by specifying the -f option when you run git push or putting a plus sign (+) in front of the branch name when pushing.

Usually your CI system will realize that your commits have changed and run again on the new commits. So if your old commits didn't meet the standard for whatever reason, that shouldn't be a factor in whether your new commits pass.

The benefit to updating the pull request is that it retains any description you've provided and any comments folks have provided on previous versions.

like image 173
bk2204 Avatar answered May 13 '26 23:05

bk2204



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!