如何自定义 git 的合并提交消息?

发布于 2024-09-07 19:34:07 字数 1093 浏览 5 评论 0 原文

每次进行合并时,我都需要生成合并提交,并且我希望它不仅仅是所有提交的摘要。

我的问题是如何格式化 git-fmt-merge-msg 或决定此自动消息的因素(我可以在提交后通过修改它并使用 git-log --pretty=format 手动执行此操作: '...')

例如我想将其格式化为这样:

 Merge branch 'test'  
    * test:  
      [BZ: #123] fifth commit subject  
      [BZ: #123] fourth commit subject  
      [BZ: #123] third commit subject  
      [BZ: #123] second commit subject  
      [BZ: #123] first commit subject  

 __________________________________________
 Merge details:  
     [BZ: #123] fifth commit subject  
               at 2010-06-30 11:29:00 +0100  
       - fifth commit body  

     [BZ: #123] fourth commit subject  
               at 2010-06-30 11:22:17 +0100  
       - fourth commit body  

     [BZ: #123] third commit subject  
               at 2010-06-30 11:21:43 +0100  
       - third commit body  

     [BZ: #123] second commit subject  
               at 2010-06-30 11:21:30 +0100  
       - second commit body  

     [BZ: #123] first commit subject  
               at 2010-06-30 11:29:57 +0100  
       - first commit body

Every time I do a merge I need for a merge commit to be generated and I would like it to have more than just the summary of all the commits.

My question is how can I format git-fmt-merge-msg or what determines this automated message (I can do this manually after a commit by amending it and using git-log --pretty=format:'...')

For example I would like to format it as such:

 Merge branch 'test'  
    * test:  
      [BZ: #123] fifth commit subject  
      [BZ: #123] fourth commit subject  
      [BZ: #123] third commit subject  
      [BZ: #123] second commit subject  
      [BZ: #123] first commit subject  

 __________________________________________
 Merge details:  
     [BZ: #123] fifth commit subject  
               at 2010-06-30 11:29:00 +0100  
       - fifth commit body  

     [BZ: #123] fourth commit subject  
               at 2010-06-30 11:22:17 +0100  
       - fourth commit body  

     [BZ: #123] third commit subject  
               at 2010-06-30 11:21:43 +0100  
       - third commit body  

     [BZ: #123] second commit subject  
               at 2010-06-30 11:21:30 +0100  
       - second commit body  

     [BZ: #123] first commit subject  
               at 2010-06-30 11:29:57 +0100  
       - first commit body

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

酷遇一生 2024-09-14 19:34:07

我知道这并没有回答最初的问题,但为了像我这样到达此页面的 git 菜鸟的利益,因为它目前是“git Change merge commit message”的第一个 Google 结果,我会提到这是可能的to:

git commit --amend -m"New commit message"

更改合并提交的提交消息,而不丢失与合并提交的任何父级的链接。

I'm aware this isn't answering the original question, but for the benefit of git noobs like myself who reach this page because it's currently the first Google result for "git change merge commit message", I'll mention that it is possible to:

git commit --amend -m"New commit message"

to change the commit message of a merge commit without losing the link to any of the parents of the merge commit.

执笔绘流年 2024-09-14 19:34:07

看起来从版本 Git 1.7.8 开始,您可以执行 git merge --edit ...
指定提交消息。

1.7.10 开始,进入编辑模式将是默认行为

从此版本开始,交互式会话中的“git merge”命令将在自动解析合并时启动编辑器,以便用户解释生成的提交,就像“git commit”命令在未执行合并时所做的那样t 给出提交消息。

(尽管我没有在 Windows 上的 msysgit 中看到它)

Looks like as of version Git 1.7.8 you can do git merge --edit ...
to specify the commit message.

And as of 1.7.10, dropping into edit mode will be the default behavior

From this release on, the "git merge" command in an interactive session will start an editor when it automatically resolves the merge for the user to explain the resulting commit, just like the "git commit" command does when it wasn't given a commit message.

(though I'm not seeing it on in msysgit on windows).

做个少女永远怀春 2024-09-14 19:34:07

我想做这样的事情。我没有找到任何合理的方法来让 git fmt-merge-msg 工作。我认为它没有按照我希望的方式工作(传递一个完全自定义的文本用于消息)。因此,我想出了另一种方法,使用 -no-commitcommit -F 命令。输出当然是可定制的,但它几乎完全反映了您所说的您想要的输出。

示例提交消息输出:

Merge branch fix4 into master

::SUMMARY::
Branch fix4 commits:
Add fix4b-4
Add fix4b-3
Add fix4b-2
Add fix4b-1

Branch master commits:
fix4b-5 on master

* * * * * * * * * * * * * * * * * * * * * * * * *
::DETAILS::
commit < 98ffa579e14610b3566e1a3f86556a04dc95a82b
Author: -----
Date:   Fri Aug 17 17:23:26 2018 -0400

    fix4b-5 on master

commit > 7e386dddee16a7c2588954d25dd6793cdaa1b562
Author: -----
Date:   Fri Aug 17 15:18:17 2018 -0400

    Add fix4b-4

    use log output as commit message

    commit 2e630b1998312ec1093d73f9fe77b942407f45e8
    Author: -----
    Date:   Fri Aug 17 15:15:28 2018 -0400

        Add fix4b-3

commit > 2e630b1998312ec1093d73f9fe77b942407f45e8
Author: -----
Date:   Fri Aug 17 15:15:28 2018 -0400

    Add fix4b-3

commit > c9bb199be49c17ca739d019d749263314f05fc46
Author: -----
Date:   Fri Aug 17 15:15:27 2018 -0400

    Add fix4b-2

commit > 5b622a935c9d078c7d0ef9e195bccf1f98cce5e4
Author: -----
Date:   Fri Aug 17 15:15:27 2018 -0400

    Add fix4b-1

用法是:

$ git mergelogmsg branch-name

我将在此处复制别名:

[alias]
    mergelogmsg = "!f() { var=$(git symbolic-ref --short HEAD) && printf 'Merge branch %s into %s\n\n::SUMMARY::\nBranch %s commits:\n' $1 $var $1 > temp_merge_msg && git log --format=format:'%s' $var..$1 >> temp_merge_msg && printf '\n\nBranch %s commits:\n' $var >> temp_merge_msg && git log --format=format:'%s' $1..$var >> temp_merge_msg && printf '\n\n* * * * * * * * * * * * * * * * * * * * * * * * *\n::DETAILS::\n' >> temp_merge_msg && git log --left-right $var...$1 >> temp_merge_msg && git merge --no-ff --no-commit $1 && git commit -eF temp_merge_msg; rm -f temp_merge_msg;}; f" 

如果您想复制并粘贴它来自定义它,请使用上面的内容。下面的版本有您不想要的换行符,但我将用它来解释我在做什么:

[alias]
1   mergelogmsg = "!f() { var=$(git symbolic-ref --short HEAD) && 
2        printf 'Merge branch %s into %s\n\n::SUMMARY::\nBranch %s commits:\n' $1 $var $1 > temp_merge_msg && 
3        git log --format=format:'%s' $var..$1 >> temp_merge_msg && 
4        printf '\n\nBranch %s commits:\n' $var >> temp_merge_msg && 
5        git log --format=format:'%s' $1..$var >> temp_merge_msg && 
6        printf '\n\n* * * * * * * * * * * * * * * * * * * * * * * * *\n::DETAILS::\n' >> temp_merge_msg && 
7        git log --left-right $var...$1 >> temp_merge_msg && 
8        git merge --no-ff --no-commit $1 && 
9        git commit -eF temp_merge_msg; rm -f temp_merge_msg;}; f"

好吧...

第 1 行 将自定义函数作为 bash shell 脚本启动,以便 git 知道它是不是 git 命令。它将当前分支(如果要将不同的分支合并到 master 中,则为 master)设置为一个变量,以便我们稍后可以使用它。
第 2 行 使用当前分支和您为原始命令指定的分支名称打印第一行(就像在普通合并命令中一样)。它将其写入临时文件。
第 3 行获取传入分支中不在当前分支中的提交的日志,并仅将这些提交的主题写入临时文件。
第 4 行将下一行打印到 temp。
第 5 行获取当前分支中不在传入分支中的提交日志,并仅将这些提交的主题写入临时文件。
第 6 行在摘要和详细信息部分之间打印一个水平分隔符。
第 7 行获取当前分支和传入分支中所有提交的日志,直到它们彼此分支或最后共享祖先之后的时间。左右给出了一个箭头,显示提交来自哪个分支。 <表示当前分支并且>表示传入分支。
第 8 行 对传入分支执行合并命令,不带快进(因此您获得提交),也不带提交(因此您必须自己编写一个...啊,但您不这样做!)
第 9 行 使用 -e-F 参数执行提交命令,以允许编辑并告诉提交使用以下内容填充消息指定文件中的文本。一旦您根据需要完成提交消息,它就会提交合并并删除临时文件。

田田!该长命令末尾的两个 ; 使 printf 函数不会写入控制台,而只会写入文件。

I wanted to do something just like this. I didn't find any reasonable way to get git fmt-merge-msg to work. I think it doesn't work the way I was hoping (passing in a completely custom text to use for the message). So instead I figured out another way using the -no-commit and commit -F commands. The output is of course customizable but it reflects almost exactly what you said you wanted the output to be.

Sample Commit Message Output:

Merge branch fix4 into master

::SUMMARY::
Branch fix4 commits:
Add fix4b-4
Add fix4b-3
Add fix4b-2
Add fix4b-1

Branch master commits:
fix4b-5 on master

* * * * * * * * * * * * * * * * * * * * * * * * *
::DETAILS::
commit < 98ffa579e14610b3566e1a3f86556a04dc95a82b
Author: -----
Date:   Fri Aug 17 17:23:26 2018 -0400

    fix4b-5 on master

commit > 7e386dddee16a7c2588954d25dd6793cdaa1b562
Author: -----
Date:   Fri Aug 17 15:18:17 2018 -0400

    Add fix4b-4

    use log output as commit message

    commit 2e630b1998312ec1093d73f9fe77b942407f45e8
    Author: -----
    Date:   Fri Aug 17 15:15:28 2018 -0400

        Add fix4b-3

commit > 2e630b1998312ec1093d73f9fe77b942407f45e8
Author: -----
Date:   Fri Aug 17 15:15:28 2018 -0400

    Add fix4b-3

commit > c9bb199be49c17ca739d019d749263314f05fc46
Author: -----
Date:   Fri Aug 17 15:15:27 2018 -0400

    Add fix4b-2

commit > 5b622a935c9d078c7d0ef9e195bccf1f98cce5e4
Author: -----
Date:   Fri Aug 17 15:15:27 2018 -0400

    Add fix4b-1

And the usage would be:

$ git mergelogmsg branch-name

I'll copy the alias here:

[alias]
    mergelogmsg = "!f() { var=$(git symbolic-ref --short HEAD) && printf 'Merge branch %s into %s\n\n::SUMMARY::\nBranch %s commits:\n' $1 $var $1 > temp_merge_msg && git log --format=format:'%s' $var..$1 >> temp_merge_msg && printf '\n\nBranch %s commits:\n' $var >> temp_merge_msg && git log --format=format:'%s' $1..$var >> temp_merge_msg && printf '\n\n* * * * * * * * * * * * * * * * * * * * * * * * *\n::DETAILS::\n' >> temp_merge_msg && git log --left-right $var...$1 >> temp_merge_msg && git merge --no-ff --no-commit $1 && git commit -eF temp_merge_msg; rm -f temp_merge_msg;}; f" 

If you want to copy and paste it to customize it, use the above. The below version has line breaks which you do not want but I'll use to explain what I'm doing:

[alias]
1   mergelogmsg = "!f() { var=$(git symbolic-ref --short HEAD) && 
2        printf 'Merge branch %s into %s\n\n::SUMMARY::\nBranch %s commits:\n' $1 $var $1 > temp_merge_msg && 
3        git log --format=format:'%s' $var..$1 >> temp_merge_msg && 
4        printf '\n\nBranch %s commits:\n' $var >> temp_merge_msg && 
5        git log --format=format:'%s' $1..$var >> temp_merge_msg && 
6        printf '\n\n* * * * * * * * * * * * * * * * * * * * * * * * *\n::DETAILS::\n' >> temp_merge_msg && 
7        git log --left-right $var...$1 >> temp_merge_msg && 
8        git merge --no-ff --no-commit $1 && 
9        git commit -eF temp_merge_msg; rm -f temp_merge_msg;}; f"

Alright...

Line 1 starts the custom function as a bash shell script so git knows it's not a git command. It sets the current branch (master if you are merging a different branch into master) to a variable so we can use it later.
Line 2 prints the first line using the current branch and the branch name you've given the original command (just as you would in a normal merge command). It writes this to a temp file.
Line 3 gets the log of the commits in the incoming branch that are not in the current branch, and writes out only the subjects of those commits to the temp file.
Line 4 prints the next line to temp.
Line 5 gets the log of the commits in the current branch that are not in the incoming branch, and writes out only the subjects of those commits to the temp file.
Line 6 prints a little horizontal separator between the summary and detail portions.
Line 7 gets the log of all the commits in the current branch and incoming branch back to the time just after they branched off from each other, or last shared an ancestor. The left-right gives an arrow that shows which branch the commit comes from. < means current branch and > means incoming branch.
Line 8 executes a merge command with the incoming branch with no fast-forward (so you get a commit) and with no commit (so you have to write one yourself... ah but you don't!)
Line 9 executes the commit command with the -e and -F parameters to allow for editing and to tell the commit to populate the message with the text in the specified file. Once you've finished the commit message as desired, it commits the merge and deletes the temp file.

Tada! The two ; at the end of that long command make it so the printf functions do not write out to the console, only to the file.

稚气少女 2024-09-14 19:34:07

我发现有两种方法可以解决这个问题

注意:不要同时使用这两种方法,因为如果提交合并失败,它会再次将日志添加到底部。

个人说明:我使用第一个解决方案,因为它完全依赖于 git 的钩子和配置属性,而不是外部脚本。
对于真正的解决方案,必须扩展名为“fmt-merge-msg”的 git 命令,该命令在传递 --log 选项时生成单行描述(如果您确实需要此解决方案,则必须创建自己的补丁(对于git)并从源代码编译)。

1.使用prepare-commit-message作为VonC建议
此解决方案存在的问题是,您需要中断提交,然后手动提交

设置将构建所需提交消息的别名:

[alias]  
lm = log --pretty=format:'%s%n   by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local

通过在 $GIT_DIR/hooks/ 中创建可执行的prepare-commit-msg 来创建prepare-commit-msg 钩子(下面的示例脚本)

#!/bin/sh
#...

case "$2,$3" in  
  merge,)  
  echo "Merge details:" >> $1  
  echo "" >> $1  
  git lm ORIG_HEAD..MERGE_HEAD >> "$1" ;;  
*) ;;  
esac  

应该定义一个别名提交消息,例如

[alias]  
m = merge --no-ff --no-commit

2。使用将自动生成合并的自定义命令
(使用在 1 中创建的 lm 别名。)

#!/bin/sh

echo ""
echo "merge with commit details -- HEAD..$1"
git merge --no-ff --no-log -m "`git lm HEAD..$1`" --no-commit $1

然后执行一个相当严格的命令:

./cmd-name <branch to merge>

如果您仍然希望获得提交的单行描述,您需要向 -m 参数添加新命令或其他内容(如果您使用 - -log 那么它会在底部生成)

I've found there are two ways for solving this problem

note: don't use both at the same time, as if the commit fails to merge it will add the log again to the bottom.

personal note: I'm using the first solution as it relies entirely on git's hooks and config properties, instead of an external script.
For a real solution one would have to extend a git command named 'fmt-merge-msg' that generates the oneline descriptions when passing the --log option (if you really need this solution you'll have to create your own patch (for git) and compile it from source).

1. using prepare-commit-message as VonC suggested
this solution has the problem that you need to interrupt the commit and then commit manually

setting an alias that will build the desired commit message:

[alias]  
lm = log --pretty=format:'%s%n   by %C(yellow)%an%Creset (%ad)%n %n%b' --date=local

creating the prepare-commit-msg hook by creating an executable prepare-commit-msg in $GIT_DIR/hooks/ (example script below)

#!/bin/sh
#...

case "$2,$3" in  
  merge,)  
  echo "Merge details:" >> $1  
  echo "" >> $1  
  git lm ORIG_HEAD..MERGE_HEAD >> "$1" ;;  
*) ;;  
esac  

one should define an alias commit msg such as

[alias]  
m = merge --no-ff --no-commit

2. using a custom command that will generate the merge automatically
(using the lm alias created in 1.)

#!/bin/sh

echo ""
echo "merge with commit details -- HEAD..$1"
git merge --no-ff --no-log -m "`git lm HEAD..$1`" --no-commit $1

and then execute a rather rigid command:

./cmd-name <branch to merge>

if you still wish to have the oneline description of the commits you'll need to add new commands or whatever to the -m argument (if you use --log then it will be generated on the bottom)

少女净妖师 2024-09-14 19:34:07

合并到 后,git 将自动提交一条消息“mergebranch ” 此

如果您想自定义 git 的合并提交消息,您可以尝试:

$ git commit --amend -m "Your merge message"

命令会将 git 的合并提交消息更新为您的提交消息,

您也可以尝试:

$ git merge <branch A> --no-commit

它会 。将 合并,并包含 's 提交列表和提交消息

If它无法快进,然后你会得到类似这样的结果:

Automatic merge went well; stopped before committing as requested

# check this with git status 
$ git status

它会告诉你,你的提交已经添加到阶段但尚未提交,因此,你可以在不运行 git add 的情况下提交它们:

$ git commit -m "your merge commit message"

如果您想更改 的最后提交消息,那么您可以再次尝试:

$ git commit --amend -m "your new commit message"

但是,通常,我们不会更新其他提交消息,除非它们不正确

假设您得到 。 git merge 后发生冲突,然后简单地解决冲突并执行以下操作:

$ git add .
$ git commit -m "your commit message"

Once you merge your <branch A> to <branch B>, git will automatically commit a message saying "merge branch <branch A> into <branch B>.

If you want to customize git's merge commit message you can try:

$ git commit --amend -m "Your merge message"

This command will update your git's merge commit message to your commit message.

you can also try :

$ git merge <branch A> --no-commit

it will merge your <branch B> with <branch A>, with list of <Branch B>'s commit and commit messages

If it fails to do fast-forward, then you will get something like this:

Automatic merge went well; stopped before committing as requested

# check this with git status 
$ git status

It will show you, your commits are already added to stage but not yet commited so, you can commit them without running git add:

$ git commit -m "your merge commit message"

If you want to change <branch B>'s last commit message then again you can try:

$ git commit --amend -m "your new commit message"

But, generally, we don't update other commit messages, unless they are incorrect.

Suppose, you get conflict after git merge, then simply resolve your conflict and do:

$ git add .
$ git commit -m "your commit message"
九局 2024-09-14 19:34:07

现在,git-merge 还有一个 --log 选项,它可以完成您想要的一半工作 - 它将短日志(提交摘要)放在合并消息中。不过,完整的解决方案必须使用 VonC 的答案中的钩子。

There's also a --log option for git-merge now, which does half of what you want - it places the shortlog (commit summaries) in the merge message. A full solution will have to use a hook like in VonC's answer, though.

叫嚣ゝ 2024-09-14 19:34:07

您可以尝试定义 prepare-commit-msg< /strong> 钩子示例一确实生成了一些自定义的“默认提交消息”)

You could try defining a prepare-commit-msg hook (the sample one does generate some custom "default commit messages")

破晓 2024-09-14 19:34:07

聚会迟到了,但现在我们可以使用
git merge --squash <分支>
将另一个分支合并到我当前分支上的单个提交并使用所有合并的提交消息预填充我们的提交消息 - 还有详细消息,而不仅仅是单行代码。
我找了很长时间才找到这个命令。

Coming late to the party, but nowadays we can just use
git merge --squash <branch>
to merge another branch into a single commit on my current branch and prepopulating our commit message with all the merged commit messages -- and the detailed messages, too, not just the one-liners.
I looked for ages for this command.

久随 2024-09-14 19:34:07

除了 Christian Severingit merge --squash 之外="https://stackoverflow.com/a/50333256/6309">答案,您现在拥有配置merge.suppressDest作为自定义(一小部分) 提交消息。

使用 Git 2.29(2020 年第 4 季度),“git merge (man) 学会了使用 merge.suppressDest 配置选择性地省略默认合并消息标题末尾的“into ”。

请参阅提交 6e6029a(2020 年 7 月 29 日)和 提交 2153192(2020 年 7 月 30 日),作者: Junio C Hamano (gitster)
(由 Junio C Hamano -- gitster -- 合并于 提交 341a196,2020 年 8 月 1 日)

fmt-merge-msg:允许合并再次省略目的地

帮助者:Linus Torvalds
帮助者:杰夫·金

在 Git 2.28 中,我们在生成默认合并消息时停止了特殊大小写“master”,只需删除末尾的代码以压制“into 'master'”消息的内容。

引入多值merge.suppressDest配置变量,该变量提供一组与要合并的分支名称相匹配的glob,以让用户指定哪个分支fmt- merge-msg 的输出应该被缩短。
如果未设置,则默认使用“master”作为变量的唯一值。

上述举措主要恢复了没有相关配置的存储库中 2.28 之前的默认设置。

git config 现在包含在其 手册页

merge.suppressDest

通过添加与集成名称匹配的 glob
分支到这个多值配置变量,
为合并到这些中而计算的默认合并消息
集成分支将省略“into
它的标题。

具有空值的元素可用于清除列表
从以前的配置条目中积累的全局变量。
当没有定义 merge.suppressDest 变量时,
master 的默认值用于向后兼容。

和:

恢复“fmt-merge-msg:停止特殊对待master

这会恢复提交 489947cee5095b168cbac111ff7bd1eadbbd90dd,该提交停止处理合并到 ' master' 分支在准备默认合并消息时是特殊的。
由于目标不是将任何单个分支指定为特殊分支,因此它通过在任何和所有分支的默认合并消息标题末尾保留“into ”来解决这个问题.
平等对待每个人的一个明显且简单的替代方案可能是为每个分支删除它,但这会导致信息丢失。

我们将引入一种新机制,让最终用户指定合并到哪些分支,并省略默认合并消息标题中的“into ”,并制定该机制,当取消配置时,再次将传统的 'master' 视为特殊的,因此我们之前对测试所做的所有更改都将变得不必要,因为这些测试将在不配置所述新机制的情况下运行。

In addition of git merge --squash mentioned in Christian Severin's answer, you now have the config merge.suppressDest as a new way to customize a (small part of the) commit message.

With Git 2.29 (Q4 2020), "git merge"(man) learned to selectively omit " into <branch>" at the end of the title of default merge message with merge.suppressDest configuration.

See commit 6e6029a (29 Jul 2020), and commit 2153192 (30 Jul 2020) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit 341a196, 01 Aug 2020)

fmt-merge-msg: allow merge destination to be omitted again

Helped-by: Linus Torvalds
Helped-by: Jeff King

In Git 2.28, we stopped special casing 'master' when producing the default merge message by just removing the code to squelch "into 'master'" at the end of the message.

Introduce multi-valued merge.suppressDest configuration variable that gives a set of globs to match against the name of the branch into which the merge is being made, to let users specify for which branch fmt-merge-msg's output should be shortened.
When it is not set, 'master' is used as the sole value of the variable by default.

The above move mostly reverts the pre-2.28 default in repositories that have no relevant configuration.

git config now includes in its man page:

merge.suppressDest

By adding a glob that matches the names of integration
branches to this multi-valued configuration variable, the
default merge message computed for merges into these
integration branches will omit " into <branch name>" from
its title.

An element with an empty value can be used to clear the list
of globs accumulated from previous configuration entries.
When there is no merge.suppressDest variable defined, the
default value of master is used for backward compatibility.

And:

Revert "fmt-merge-msg: stop treating master specially"

This reverts commit 489947cee5095b168cbac111ff7bd1eadbbd90dd, which stopped treating merges into the 'master' branch as special when preparing the default merge message.
As the goal was not to have any single branch designated as special, it solved it by leaving the "into <branchname>" at the end of the title of the default merge message for any and all branches.
An obvious and easy alternative to treat everybody equally could have been to remove it for every branch, but that involves loss of information.

We'll introduce a new mechanism to let end-users specify merges into which branches would omit the "into <branchname>" from the title of the default merge message, and make the mechanism, when unconfigured, treat the traditional 'master' special again, so all the changes to the tests we made earlier will become unnecessary, as these tests will be run without configuring the said new mechanism.

无尽的现实 2024-09-14 19:34:07

一个非常简单的 bash 函数,设置默认消息并添加您的参数。
如果您想进行更改,它会使用 --edit 开关打开您的编辑器。

编辑 ~/.bashrc 或 bash_aliases。 (不要忘记 source ~/.bashrc)在 bashrc 中应用更改,

function mergedevelop()
{
    git merge --no-ff --edit -m "master <-- develop: $1" develop;
}

使用:

mergedevelop "PR #143..." 得到消息:

master < -- 开发:PR #143...

A very simple bash function that set's a default message and adds your argument.
It opens your editor with the --edit switch if you want make changes.

edit ~/.bashrc or bash_aliases. (Don't forget to source ~/.bashrc) to apply changes in your bashrc

function mergedevelop()
{
    git merge --no-ff --edit -m "master <-- develop: $1" develop;
}

use:

mergedevelop "PR #143..." to have message:

master <-- develop: PR #143...

想你的星星会说话 2024-09-14 19:34:07

您可以使用以下命令在合并期间覆盖或自定义合并消息:

git merge <branch> -m "<merge message>"

它已在 git 版本 2.34 上进行了测试,如果您安装了 git,则可以通过键入“git merge --help”在文档中找到它,或者在 git-merge 在回答这个问题时。

You can override or customize a merge message during the merge with the command below:

git merge <branch> -m "<merge message>"

It was tested on git version 2.34, you can find it on the documentation by typing "git merge --help" if you have git installed, or at git-merge at the time of this answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文