My submitted PR includes my PR from the project - how to remove?

I submitted a PR where for the first time I edited multiple files. Previous PRs I have submitted were only editing one file, which the GitHub interface makes very seamless and simple for those of us new to submitting PRs.

For the PR I submitted, I already had a fork of the project, but it was not updated with the latest of the Master branch for the main project, so I updated it.

I then edited two of the files in my fork.

I then submitted the fork to the project thinking it would only add the two edited files to the PR.

However, as you can see here, the PR contains 3 commits, one of which is the update I did to my fork.

Is it necessary for me to remove this from the PR? IOW, will this cause problems on the maintainer’s side if they accept the PR?

Is it possible for me to remove the commit from the existing PR? Or is it better to submit a new one?

What might have been the better way for me to submit these two edited files? I’m still not sure how I should accomplish this.

Thank you.

It looks like you updated your fork through a pull request. That’s always going to create an extra merge commit, which is then going to show up in your pull request. To avoid that you need to update your fork manually.

Technically it’d be possible to just merge anyway, but if I were the maintainer of the upstream project I’d require you to fix the PR before merging.

The procedure I’d use to fix this is as follows:

  1. In your local copy of the repository (on your computer) rename the master branch to something like backup. You’ll need it later to get the commits you want to keep and put into the pull request.
  2. Add the upstream repository as a remote of your local repository (e.g. called upstream, see also Git - Working with Remotes). Check out its master branch.
  3. From there create a new branch for your feature. You’ll use that for the PR later.
  4. Cherry-pick the two commits you want to the feature branch.
  5. Push the feature branch and the new master branch (now identical to upstream) to your GitHub repository. You’ll need to force-push master to override the changes you made there.
  6. Finally, create a PR from your feature branch (or update the existing one, I’m not sure if you can change the source branch).

For future work, you can skip 1, replace 2 with pulling from the upstream repo, and replace 4 with making the changes you want, and you shouldn’t need to force-push.

In this case, I did all of the editing directly through the GitHub interface, so I have no local copy of the repository - I should have mentioned this.

I don’t think there is any way to fix this through the web interface, unless you want to delete your fork, recreate it (to get the latest upstream version), and then redo your commits.

It’s up to you how you want to work, but I highly recommend getting used to working with Git locally. :slightly_smiling_face:

I was looking at that. There is one previously accepted commit from my current repo - will cause any problems anywhere?

I was already thinking this after looking at several pages in the various search results. Where I confused myself was thinking that editing within GitHub was an easier way to go about things.

If it’s merged in the upstream repository it will stay there, whether you delete your fork or not. Only changes that are only in your fork will be lost. So you probably want to save the changed files from your PR first, if you go that route.

It might be if you’re not familiar with Git yet, but the GitHub website exposes only a small subset of what Git can do. Maybe that’s why it looked simpler. :wink:

1 Like