nfm*_*nfm 75 git version-control commit-message
我正在运行一个非常快速的代码编译测试循环,我经常修改我的提交更改.
例如:
# Make some changes
$ git commit -m "Added feature X"
# Compile, test
# Fix bugs
$ git commit -a --amend
Run Code Online (Sandbox Code Playgroud)
修复bug后,我通常需要相同的提交消息.有没有办法让git跳过我的EDITOR只是使用原始提交消息?
Ada*_*ruk 87
您只需添加--no-edit即可使用上一条消息.此选项自2005年以来就存在,但仅在最近才启用该--amend选项.
另一种方法是-C HEAD使用修改选项添加到commit命令.这允许您不仅使用当前提交的消息,而且可以指定您喜欢的任何其他引用,因此值得记住它.
当从历史记录中的各个位置构造提交并使用其中一个提交的消息时,这尤其有用.例如:
git checkout feature1^^ -- database/table1.sql
git checkout feature1^^^^ -- logger.py
git add -A && git commit -C feature1
Run Code Online (Sandbox Code Playgroud)
它只使用来自feature1的2次提交,并使用上次提交中的提交消息到feature1 - 如果这是一个很好的描述.
小智 7
你也可以使用
--reuse-message=<commit>
Take an existing commit object, and reuse the log message and the authorship
information (including the timestamp) when creating the commit.
Run Code Online (Sandbox Code Playgroud)
这允许您使用以前的提交消息.这也可以是脚本或git别名的一部分.