I've messed up a PR

This is the PR:

  • Commits b85317e and 3d28647 are ok.
  • Then (my first time using GitHub desktop) I’ve somehow merged develop into my branch.
  • Then I’ve tried a git rebase 3d28647 and things got worst.
  • Commit 110ecfc is OK.

Can someone tell me how to fix this (possibly on the command line)? Pretty sure that James can merge my branch doing a cleanup, but I’d like not to leave such a mess…

2 Likes

Since the first two commits are OK we can keep them, and reset your fix-wp-cli branch to point only to those two commits for now:

git checkout 3d28647 -B fix-wp-cli

Now we need to grab the 3rd commit:

git cherry-pick 110ecfc

The commit hash of this commit will change, but that’s fine. Now we just need to push the branch back up to the PR.

I am going to assume that you have your xxsimoxx/ClassicPress GitHub repository set as a git remote named origin. You can verify this by running git remote -v, and if it’s something other than origin then you can replace it in the command below:

git push origin fix-wp-cli

You should have gotten an error indicating that the history in your fix-wp-cli branch has diverged from the copy of that branch on GitHub. You can add the -f or --force option to push anyway, but I recommend always trying to push without the -f option first, as a check to make sure git is trying to do what you expect.

git push -f origin fix-wp-cli

Now the PR should look as expected on GitHub.

There’s no need to rebase or merge here, since this PR is adding a new file there is basically no chance of a conflict.

2 Likes

Thank you very much!
Today I’ve learned something new :smiley:

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.