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
How do I turn off "Prepend commit bodies in gh pr create with templates #1570"? #10751
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.
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.
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.
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.
Activity
williammartin commentedon Apr 15, 2025
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
.githuborg repo) you can probably achieve some of what you want with a combination of--body-fileand--editor.For example:
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:
And use it like:
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.
ElijahLynn commentedon Apr 22, 2025
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.
williammartin commentedon Apr 22, 2025
I'm not sure if you're saying that's a good thing or not, but just to be clear, with the
--editorflag 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.ElijahLynn commentedon Apr 22, 2025
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!
ElijahLynn commentedon Apr 22, 2025
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 --editorfix(repo): add pull_request_template scaffolding ## Related contract (#…
fix(source-control): scaffold ## Related section in pull-request crea…