Determine how a pull request was merged

I’m working on an action to backport PRs to branches. If a PR was squashed and merged I’d like to cherry-pick the squashed commit back to the other branch rather than each commit in the PR and then squash and merge that PR.

Is there a way to tell how a pull request was merged i.e whether it was a merge, squash or rebase?

Hi @ewanharris,

It’s hard to tell how a pull request was merged. Basically the differences are in the commit history.
For squash merge, there will be only one combined commit on base branch, while for common merge, at least 2 commits. For rebase merge, the committer is not changed, for squash merge, it’s changed to ‘Github’.

If you auto merge the PR with an action, you can check the action details about the code of merge, it should be hardcoded.
If you manually merge the PR, you can add a comment or a label to indicate how it’s merged as a workaround.