0

I have a fork of a repository by another person, which I also use as upstream in my local fork.

I pull requested (or how this is called) two commits to the upstreams master branch. They are not merged there yet. Later I fetched the latest changes from this upstream via the GitHub page, and pulled them into my local repo via GitHub Desktop. So now my GitHub page says my fork is three commits ahead of the upstream and my two commits are in my local repo, and the fetched commits after them.

The repo owner now asks me to pull request (or how this is called) these changes to another branch in his repo.

What is the proper way to undo the two pull requested, unmerged commits in the master branch? Can I just revert them in GitHub desktop, push the commits and close the pull request? Will this resolve everything in the other repo? And will this make the 'three commits ahead' message in my fork disappear?

Nils Lindemann
  • 1,146
  • 1
  • 16
  • 26
  • 1
    You should be able to change the branch from the github site itself without undoing anything, check your pull request link – jcesarmobile Jan 10 '22 at 01:13
  • 1
    It seems like you could change the [base branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request) from `master` to `tiddlywiki-com`, and that would fix the problem. Does that work for you? – Nick ODell Jan 10 '22 at 01:13
  • Thanks for the hint that I can change the base branch from GitHub. If the Pull request doesn't appear under the tab _Pull requests_, it can also be done directly on the page of the pull request (button _Edit_). – Nils Lindemann Jan 10 '22 at 11:41

2 Answers2

1

Try

git revert <unmerged_commit_1_hash>
git revert <unmerged_commit_2_hash>

it will remove your two unwanted commits, and keep new commits

  • 1
    Yes, that is the clean way, when other repositories are affected. This creates two new commits which undo the unwanted commits. – Nils Lindemann Jan 10 '22 at 11:47
0

I closed the pull request on GitHub. Then I resetted the local master hard to the state before my two commits, and force pushed it to my GitHub forks master (as described here). That is ok, because no one else listens to it. Then I fetched and pulled the master again, and it is now in a clean state again, without my two commits. Then I created a new pull request from and to the desired branch.

Nils Lindemann
  • 1,146
  • 1
  • 16
  • 26