U r s u s
U r s u s

Reputation: 6968

Pull Request closed unexpectedly

I opened a PR and then realised I wanted to revert the latest commit. So I did

git reset --hard HEAD~1

then worked on the new changes and did

git push --force-with-lease

As a very unexpected result the PR got closed.

enter image description here

One thing I should add is that I forcefully pushed before actually adding any commits. Could that be why the PR was closed?

Upvotes: 1

Views: 1936

Answers (2)

poke
poke

Reputation: 387527

GitHub will automatically monitor the branches for pull requests, so changes to the branch will be reflected in the pull request. The primary use case for this is simple updates to address code review. It is not limited to simple commit additions though but to any changes on the branch. So for example, a rebase that rewrote the history (e.g. to incorporate code changes) will also appear in the pull request, replacing the previous commits in it.

So when you force-pushed your branch after you reverted it back to master, you essentially emptied out the pull request. So when GitHub checked the branch for the pull request, it noticed that the upstream’s master already contained “all changes” from the pull request (since there were none).

This automatically triggers the pull request resolution from GitHub and closes the pull request.

Upvotes: 4

axiac
axiac

Reputation: 72177

As a very unexpected result the PR got closed..

The message in the screenshot says something else: the pull request was "successfully merged and closed".

This should not be an unexpected result. Merging your branch into the target branch of the PR is the reason you did the PR, in the first place.

You omitted from the equation that, when you create a PR, the owner of the project is notified about it. I suspect they reviewed your PR and merged it while you were reworking the changes on the branch. Then you attempted to rebase the branch but, because the PR was already merged and closed, Github doesn't update the PR any more.


It is possible to push new commits and even to rebase a branch that is involved in a Pull Request and Github dutifully keeps the Pull Request up to date with all the changes on the branch. But after the Pull Request is closed (merged or not), it becomes part of the history and it is not updated any more.

Upvotes: 0

Related Questions