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
Allow editing the commit message when squash-merging a PR #1023
Describe the feature or problem you’d like to solve
When performing a squash and merge on a pull request through the web interface, you can edit the commit message and extended description. By default, this is prepopulated with a list of all of the commit messages included in the pull request. I often find myself deleting some of the lines from this section because the additional commits are usually related to feedback brought up during the code review, and would be irrelevant or confusing when viewing in the context of the final commit.
When merging a PR through the CLI, the same commit message is generated as the web interface, but there is no option to edit the commit message.
Proposed solution
Open the user's default terminal editor to allow the PR maintainer to enter the commit message. By default, prepopulate the editor with the default generated message so the user can easily just save and exit the editor to continue using the current behaviour.
Reacted by Kapil Thangavelu, Joongi Kim, Liv Stowe, Matthew Gabeler-Lee, Reef Turner, Aliabbas Merchant, Chandler Carruth, Niels Lohmann, Steven Grimm, Geoffrey Martin-Noble and 27 more
I think this is more serious than an "enhancement".
In the GitHub web UI, the "squash and merge" button always opens a text box to prompt editing the commit message.
The git pr merge --squash command gives no indication that it will directly commit without any option to edit the commit message. This is extremely surprising and results in a bad history for repositories. At the very least, there needs to be an unambiguous prompt prior to this happening as this is not a local operation or easily undone.
Reacted by Niels Lohmann, Clare Macrae, Nagy-Egri Máté Ferenc, Muhammad Falak R Wani, Guilhem, Fabian Löschner, pakoy3k, Steven Grimm, Geoffrey Martin-Noble, Souji and 14 more
The @krlmlr suggestion for the non-interactive mode is also very useful when you use tools and conventions like conventional-commits and semantic-release where both title and body of the commit are used to detect the next semantic version to release.
Actually, except for a github enterprise on-premise version, there is no way to check/lint the body message of a squashed PR and doing that manually or through some browser extension is not ideal.
Adding a -m option will allow to squash the PR from the command line with a prelinted body and title
building off of @krlmlr 's comment. It could be useful to have the whole sub command take an argument that would be the message, similar to how git commit -m works; so something like this
gh pr merge 123 -m "the commit message I want"
This could work the same for all the flags too not just m , basically changing the usage to something like this
I intend to merge #2810 but think this issue should remain open so we can discuss having an interactive prompt for this as well. @mislav do you recall if there was a technical reason for us not including that to begin with? @ampinsk do you recall if there was a UX reason?
In addition to interactive prompting mode, the other thing #1023doesn't cover is setting the first line of the commit, which is important for some CI flows (e.g. commit message validation, semantic versioning release automation e.g. through conventional commits)
Editing the commit message should prepopulate the user's editor with a precomputed headline/body. The web UI splits out the headline as a separate input, but I think it's okay to have it be the top line of the file opened in the editor.
Is there any way to change the commit message "title" (as shown in git log --oneline)? The new --body argument introduced with #2810 only seems to append its value to the default title "Merge pull request #... from ..." instead of allowing to define the entire commit message.
Reacted by Marco Vettorello, Reef Turner and bl-ue
When performing a squash and merge on a pull request through the web interface, you can edit the commit message and extended description
#2980 only permits editing the body, not the first line of the message. It has some internal code for setting the "headline", but no ability to invoke that code from the CLI AFAICT:
Compare:
It is great to heart that this feature is finally implemented.
However, I just faced a caveat: editing the commit message is only prompted when pr merge is executed in the interactive mode ONLY, meaning that pr merge --squash still does not have chances to change the commit message interactively.
I think this is an acceptable complexity trade-off for handling scripted usage and interactive usage, but at least this should be documented somewhere, e.g., "When you specify the merge method explicitly via --merge / --rebase / --squash arguments, it runs in the non-interactive mode and the commit message is automatically filled unless specified with the --body argument".
Reacted by Reef Turner, Mislav Marohnić, bl-ue and Nate Smith
Any timelines to fix the issue of changing first line of commit message when doing pr merge operation? As others have mentioned before, there is a need to consolidate the comments during pr merge operation for those who follow Conventional Commit message format. Thanks for adding -b option for commit body though.
Reacted by Marco Vettorello, bl-ue and Quentin Danjou
Thanks for the feedback, everyone. Reopening as a feature request to be able to edit the commit subject message as well as the commit body.
Thanks a lot. Since I am not familiar with GH CLI release cycles, would it be possible to get a rough timeline on release when this feature would be available?
@Ashish-Pandey-Imprivata We don't know. If someone wants to step up and contribute the code for feature via a pull request, it might get released within the next few weeks. Otherwise, it's going to be whenever we find time to get to this.
In the meantime, this manual approach will work with existing versions of GitHub CLI:
Activity
mgabeler-lee-6rs commentedon Jun 25, 2020
I'd like to be able to edit the commit message for all merges, not just squash ones.
My use case: I want/need my merge commits to have a conventional commit format to support
semrelautomationchandlerc commentedon Jul 1, 2020
I think this is more serious than an "enhancement".
In the GitHub web UI, the "squash and merge" button always opens a text box to prompt editing the commit message.
The
git pr merge --squashcommand gives no indication that it will directly commit without any option to edit the commit message. This is extremely surprising and results in a bad history for repositories. At the very least, there needs to be an unambiguous prompt prior to this happening as this is not a local operation or easily undone.krlmlr commentedon Jul 13, 2020
Could we also offer an
-mor--messageargument that allows editing the message in non-interactive mode?markov00 commentedon Oct 5, 2020
The @krlmlr suggestion for the non-interactive mode is also very useful when you use tools and conventions like conventional-commits and semantic-release where both title and body of the commit are used to detect the next semantic version to release.
Actually, except for a github enterprise on-premise version, there is no way to check/lint the body message of a squashed PR and doing that manually or through some browser extension is not ideal.
Adding a
-moption will allow to squash the PR from the command line with a prelinted body and titleandres-lowrie commentedon Nov 11, 2020
building off of @krlmlr 's comment. It could be useful to have the whole sub command take an argument that would be the message, similar to how
git commit -mworks; so something like thisThis could work the same for all the flags too not just
m, basically changing the usage to something like thisvilmibm commentedon Jan 21, 2021
I intend to merge #2810 but think this issue should remain open so we can discuss having an interactive prompt for this as well. @mislav do you recall if there was a technical reason for us not including that to begin with? @ampinsk do you recall if there was a UX reason?
mgabeler-lee-6rs commentedon Jan 22, 2021
In addition to interactive prompting mode, the other thing #1023 doesn't cover is setting the first line of the commit, which is important for some CI flows (e.g. commit message validation, semantic versioning release automation e.g. through conventional commits)
vilmibm commentedon Jan 23, 2021
We just didn't get to adding an interactive prompt for this and agreed internally it's a good idea.
The spec for this is converting the confirmation prompt from a
y/Nprompt to a select with options:Editing the commit message should prepopulate the user's editor with a precomputed headline/body. The web UI splits out the headline as a separate input, but I think it's okay to have it be the top line of the file opened in the editor.
cristiand391 commentedon Jan 24, 2021
I'm working on this issue.
rfkd commentedon Jan 29, 2021
Is there any way to change the commit message "title" (as shown in
git log --oneline)? The new--bodyargument introduced with #2810 only seems to append its value to the default title "Merge pull request #... from ..." instead of allowing to define the entire commit message.mgabeler-lee-6rs commentedon Feb 17, 2021
I don't agree that #2980 resolves this
#2980 only permits editing the body, not the first line of the message. It has some internal code for setting the "headline", but no ability to invoke that code from the CLI AFAICT:
Compare:
achimnol commentedon Feb 22, 2021
It is great to heart that this feature is finally implemented.
However, I just faced a caveat: editing the commit message is only prompted when
pr mergeis executed in the interactive mode ONLY, meaning thatpr merge --squashstill does not have chances to change the commit message interactively.I think this is an acceptable complexity trade-off for handling scripted usage and interactive usage, but at least this should be documented somewhere, e.g., "When you specify the merge method explicitly via
--merge/--rebase/--squasharguments, it runs in the non-interactive mode and the commit message is automatically filled unless specified with the--bodyargument".Ashish-Pandey-Imprivata commentedon Mar 16, 2021
Any timelines to fix the issue of changing first line of commit message when doing
pr mergeoperation? As others have mentioned before, there is a need to consolidate the comments duringpr mergeoperation for those who follow Conventional Commit message format. Thanks for adding-boption for commit body though.mislav commentedon Mar 17, 2021
Thanks for the feedback, everyone. Reopening as a feature request to be able to edit the commit subject message as well as the commit body.
Ashish-Pandey-Imprivata commentedon Mar 17, 2021
Thanks a lot. Since I am not familiar with GH CLI release cycles, would it be possible to get a rough timeline on release when this feature would be available?
mislav commentedon Mar 18, 2021
@Ashish-Pandey-Imprivata We don't know. If someone wants to step up and contribute the code for feature via a pull request, it might get released within the next few weeks. Otherwise, it's going to be whenever we find time to get to this.
In the meantime, this manual approach will work with existing versions of GitHub CLI:
It can be saved as an alias:
Ashish-Pandey-Imprivata commentedon Mar 18, 2021
Thanks for your comment and suggestions for a good workaround in the meantime. Using "gh api" is slightly involved, but works fine.
mislav commentedon Jan 31, 2022
This shipped in v2.4.0, forgot to close: f2d23d8