You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request] Do not overwrite existing pull request if the branch has been touched by others #4161
We have a workflow where we open a pull request to update a file, on schedule. We'd like to keep updating the PR, if already opened and not merged, only if the content of the branch hasn't been touched by other users. Would that be an acceptable feature request for this workflow? 🙂 CC: @wsmoses
Reacted by Steve Mason, Nicola Soranzo and Malix - Alix Brunet
// Reset the branch if one of the following conditions is true.
// - If the branch differs from the recreated temp branch.
// - If the number of commits ahead of the base branch differs between the branch and
// temp branch. This catches a case where the base branch has been force pushed to
// a new commit.
// - If the recreated temp branch is not ahead of the base. This means there will be
// no pull request diff after the branch is reset. This will reset any undeleted
// branches after merging. In particular, it catches a case where the branch was
// squash merged but not deleted. We need to reset to make sure it doesn't appear
// to have a diff with the base due to different commits for the same changes.
// - If the diff of the commits ahead of the base branch differs between the branch and
// temp branch. This catches a case where changes have been partially merged to the
// base. The overall diff is the same, but the branch needs to be rebased to show
// the correct diff.
we'd like more logic to handle the case "if there's only one commit ahead of the target branch, then push and we're all happy, otherwise exit silently because we think someone else pushed fixes that we shouldn't really overwrite"
I have considered this in the past and I don't think I came up with a good solution. I would be open to adding this feature, but I would need to give this a lot more thought. I'll try and find some time.
@peter-evans I think this issue is more generalizable as a feature request for commit stacking (instead of the current commit amending)
For example: a lot of workflows using this action as dependencies are update workflows, whose PRs might stay open for more than one cycle
Currently, the commits are always amended (force-pushed)
If an update commit from cycle 1 passes but an update commit from cycle 2 fails OR like @giordano's workflow, if there are subsequent commits; that information and work would be lost by amending
An option to stack commits instead of amending them would make such workflows be able to use this action
Arguably, when implemented, it could even be made default, since GitHub proposes "squash and merge" if needed
Activity
giordano commentedon Sep 16, 2025
Basically around
create-pull-request/src/create-or-update-branch.ts
Lines 297 to 310 in 915d841
peter-evans commentedon Dec 2, 2025
Hi @giordano
I have considered this in the past and I don't think I came up with a good solution. I would be open to adding this feature, but I would need to give this a lot more thought. I'll try and find some time.
Malix-Labs commentedon Jun 15, 2026
@peter-evans I think this issue is more generalizable as a feature request for commit stacking (instead of the current commit amending)
For example: a lot of workflows using this action as dependencies are update workflows, whose PRs might stay open for more than one cycle
Currently, the commits are always amended (force-pushed)
If an update commit from cycle 1 passes but an update commit from cycle 2 fails OR like @giordano's workflow, if there are subsequent commits; that information and work would be lost by amending
An option to stack commits instead of amending them would make such workflows be able to use this action
Arguably, when implemented, it could even be made default, since GitHub proposes "squash and merge" if needed