偶尔我会进入故障排除模式,并提交/推送一些小但是分离的commit,带有类似于“在Heroku部署期间排除<某些东西>问题”的注释。我想每次提交时都使用相同的注释而不必重新输入。这可能吗?
偶尔我会进入故障排除模式,并提交/推送一些小但是分离的commit,带有类似于“在Heroku部署期间排除<某些东西>问题”的注释。我想每次提交时都使用相同的注释而不必重新输入。这可能吗?
来自git-commit(1)命令的文档:
-C <commit>
--reuse-message=<commit>
Take an existing commit object, and reuse the log message and the authorship
information (including the timestamp) when creating the commit.
-c <commit>
--reedit-message=<commit>
Like -C, but with -c the editor is invoked, so that the user can further edit
the commit message.
使用以下方式是可能的:
git commit --reuse-message=HEAD
更新:
您可能还需要使用--reset-author
选项,
--reset-author
When used with -C/-c/--amend options, declare that the authorship of the
resulting commit now belongs of the committer. This also renews the author
timestamp.
git commit -a --reuse-message=HEAD
,它怎么可能拉取除了我最近的提交评论以外的任何东西?另一个团队成员的评论如何通过该命令和上下文悄悄地混入其中? - Seth起初,我回答道:
我猜
git commit --reuse-message=HEAD
可以做到这一点。
然后我想这不是你想要的,于是删除了它。然后生活赶上了我,AFK了几个小时。无论如何,尽管已经有一个被接受的答案,但我会建议:
$ git config alias.troubleshoot '!troubleshoot() { git add -u && git commit -m "Troubleshooting the $1 during deployment to Heroku."; }; troubleshoot'
并且您可以按照以下方式使用它:
git troubleshoot foo
将使用"在部署到Heroku期间排除故障foo "作为提交消息提交更改(和最终新文件)。
.git/COMMIT_EDITMSG 包含最后一次提交的信息。https://git-scm.com/docs/git-commit#_files
git commit --file .git/COMMIT_EDITMSG
将使用该文件作为提交信息。
--edit
参数。 - pcworld~/LastCommitMessage.txt
。 然后,像这样指定此消息作为您的默认(全局)提交消息:$ git config --global commit.template ~/LastCommitMessage.txt
您可以通过不使用 --global 并使用其他替代方法来缩小范围。
您可以通过打开位于主目录中的 .gitconfig
文件轻松访问所有 git 设置。打开该文件并删除上述设置,以便在完成所有提交后取消设置。