有没有办法让“gitcherry-pick-x”?只记录最近的“cherry-picked from”信息?

发布于 2025-01-10 19:33:51 字数 647 浏览 0 评论 0原文

当我们使用 gitcherry-pick -x时,它会在提交消息中记录源提交,如下 (cherry pick from commit 5f2662a29efaa91af6b356df2d5d1df69017cac1)

我有一堆我需要不断从一个基础分支迁移到下一个分支的提交。如果我使用cherry-pick -x,它会不断将最新的源提交添加到消息中。

假设我已使用cherry-pick -x 迁移提交两次,我的提交消息如下所示:

commit fb3bead084edc27267219d9a8e088ac613159f69 (my-new-branch)
Author: ----
Date:   Thu Feb 17 15:29:15 2022 +0530

    Test commit 1

    (cherry picked from commit 5f2662a29efaa91af6b356df2d5d1df69017cac1)
    (cherry picked from commit 11c6ca55b06cbf333fff9a3cfd50c6617adc2e77)

如果已有消息,是否有办法使cherry-pick -x 覆盖“cherry pick from”消息? 我只想记录最近的源提交。

When we use git cherry-pick -x <commit>, it records the source commit in the commit message as follows (cherry picked from commit 5f2662a29efaa91af6b356df2d5d1df69017cac1)

I have a bunch of commits which I need to keep migrating from one base branch to the next. If I use cherry-pick -x, it keeps adding the latest source commit to the message.

Suppose I have used cherry-pick -x to migrate the commit twice, my commit message looks like below:

commit fb3bead084edc27267219d9a8e088ac613159f69 (my-new-branch)
Author: ----
Date:   Thu Feb 17 15:29:15 2022 +0530

    Test commit 1

    (cherry picked from commit 5f2662a29efaa91af6b356df2d5d1df69017cac1)
    (cherry picked from commit 11c6ca55b06cbf333fff9a3cfd50c6617adc2e77)

Is there way make cherry-pick -x overwrite the 'cherry picked from' message if there is already one?
I want to record only the most recent source commit.

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

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

发布评论

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

评论(1

小鸟爱天空丶 2025-01-17 19:33:51

不,这就是它的工作原理。

但你还有其他选择:

  1. 你可以使用 --edit 选项(感谢 @joanis 在评论中指出)

使用此选项,gitcherry-pick 将允许您在提交之前编辑提交消息。

  1. 您可以使用 --no-commit 选项并在实际提交之前更改消息。

通常该命令会自动创建一系列提交。该标志应用必要的更改来挑选每个命名的
提交到您的工作树和索引,而不进行任何提交。
此外,当使用此选项时,您的索引不必
匹配 HEAD 提交。樱桃采摘是从一开始就完成的
您的索引状态。

当连续挑选多个提交对索引的影响时,这非常有用。

No, that's the way it works.

But you have alternatives:

  1. You can use the --edit option (thanks @joanis for pointing out in the comments)

With this option, git cherry-pick will let you edit the commit message prior to committing.

  1. You can use the --no-commit option and change the message before actually committing it.

Usually the command automatically creates a sequence of commits. This flag applies the changes necessary to cherry-pick each named
commit to your working tree and the index, without making any commit.
In addition, when this option is used, your index does not have to
match the HEAD commit. The cherry-pick is done against the beginning
state of your index.

This is useful when cherry-picking more than one commits' effect to your index in a row.

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