Skip to content

How do I turn off "Prepend commit bodies in gh pr create with templates #1570"? #10751

Open

Description

@ElijahLynn

I keep having my commit messages prepended to the body of a PR template. This is not useful to my PRs, and causes extra work for me to remove them.

Looks like this was intentionally added in:

How do I turn this off?

Activity

  1. added
    bug
    on Apr 8, 2025
  2. added
    needs-triage
    on Apr 8, 2025
  3. added
    enhancement
    gh-pr
    and removed
    bug
    on Apr 15, 2025
  4. williammartin commented on Apr 15, 2025

    @williammartin
    Member

    Hey @ElijahLynn,

    Thanks for opening this issue and letting us know about your use case. There is no first class support for avoiding this behaviour, however, if your PR template exists within the repository you are targeting (as opposed to living in a .github org repo) you can probably achieve some of what you want with a combination of --body-file and --editor.

    For example:

    gh pr create --title "my pr" --body-file .github/PULL_REQUEST_TEMPLATE.md --editor
    

    Will open your editor with the first line being the title and the template being the rest of the contents, with no commits prepended.

    You could also alias this like:

    gh alias set my-pr-create 'pr create --body-file .github/PULL_REQUEST_TEMPLATE.md --editor`
    

    And use it like:

    gh my-pr-create --title ...
    

    Since this behaviour has been in place for nearly 5 years, and I can't find any other instances of people wanting different behaviour, I'm hesitant to add a new flag or configuration option for this, but I'm happy to leave this open and see whether other people have interest in the feature.

  5. removed
    needs-triage
    on Apr 15, 2025
  6. ElijahLynn commented on Apr 22, 2025

    @ElijahLynn
    Author

    Thanks so much for the ideas William!

    When I run gh pr create --title "my pr" --body-file .github/pull_request_template.md --editor (opens in Cursor)

    I get the title embedded at the top of the PR before the template now.

    Image

  7. williammartin commented on Apr 22, 2025

    @williammartin
    Member

    I'm not sure if you're saying that's a good thing or not, but just to be clear, with the --editor flag this is expected as it's intended to capture both title and body. I think it's explained in the snippet at the bottom of the file.

  8. ElijahLynn commented on Apr 22, 2025

    @ElijahLynn
    Author

    Oh, yeah, not a good thing, unless the first line is the title?

    Oh, I see now, I had no idea, that is actually useful, thanks!

    ------------------------ >8 ------------------------
    
    Please Enter the title on the first line and the body on subsequent lines.
    Lines below dotted lines will be ignored, and an empty title aborts the creation process.
    
  9. ElijahLynn commented on Apr 22, 2025

    @ElijahLynn
    Author

    worth noting for anyone else reading this, that if you leave off the --title, which is my preference so I can have a single command in my history, then it uses the branch name as the first line/title.

    gh pr create --body-file .github/pull_request_template.md --editor

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

    enhancementgh-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions