如何跳过" git commit --amend"中的提交消息步骤? [英] How to skip the commit message step in "git commit --amend"?

查看:194
本文介绍了如何跳过" git commit --amend"中的提交消息步骤?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个非常快速的代码 - 编译 - 测试循环,我修改提交的次数往往比没有更多。



例如:

 #进行一些更改
$ git commit -m新增功能X
#编译,测试
#修复bug
$ git commit -a --amend

我通常希望我修正了我的错误后,提交相同的消息。有没有办法让git跳过我的编辑器并只使用原始提交信息?

解决方案

您可以添加 - no-edit 来使用最后一条消息。该选项自2005年以来一直存在,但最近才启用了 - 修改选项。

另一种方式是使用修改选项将 -C-HEAD 添加到commit命令中。这允许你不仅仅使用当前提交的消息,而且你可以指定任何你喜欢的引用,所以值得记住它。



这在构造提交时特别有用来自历史的各个地方并使用其中一个提交的消息。例如:

  git checkout feature1 ^^  -  database / table1.sql 
git checkout feature1 ^^^^ - logger.py
git add -A&& git commit -c feature1

这将使用来自feature1的2个提交并使用来自最后提交到feature1 - 如果这是一个很好的描述。


I'm running a very rapid code-compile-test loop where I am amending changes to my commits far more often than not.

For example:

# Make some changes
$ git commit -m "Added feature X"
# Compile, test
# Fix bugs
$ git commit -a --amend

I usually want the same commit message after I fix my bugs. Is there a way to make git skip firing up my EDITOR and just use the original commit message?

解决方案

You can just add --no-edit to use the last message. This option existed since 2005 but only recently has been enabled for the --amend option.

The other way is to add -C HEAD to the commit command with amend option. This allows you to not just use the current commit's message but you can specify any other reference you like, so it's worth remembering it.

This is particularly useful when constructing a commit from various places in history and using one of those commit's messages. For example:

git checkout feature1^^ -- database/table1.sql
git checkout feature1^^^^ -- logger.py
git add -A && git commit -C feature1

which would just use 2 commits from a feature1 and use the commit message from the last commit to feature1 - if that was a good description.

这篇关于如何跳过" git commit --amend"中的提交消息步骤?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆