Skip to content

[Feature Request] Do not overwrite existing pull request if the branch has been touched by others #4161

Open

Description

@giordano

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

Activity

  1. giordano commented on Sep 16, 2025

    @giordano
    Author

    Basically around

    // 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"

  2. peter-evans commented on Dec 2, 2025

    @peter-evans
    Owner

    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.

  3. Malix-Labs commented on Jun 15, 2026

    @Malix-Labs

    @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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions