Git:如何在'git reset'后重用/保留提交消息? [英] Git: How to reuse/retain commit messages after 'git reset'?
问题描述
git reset HEAD〜1
#hack,fix,hack
git提交-a
#argh ..我需要重新键入我的消息吗?
我认为合理的组合提交信息非常严重。它们通常包含带有参考文献<改变的理由。直到现在,我对通过未分类的 git reflog
, git log $ c $恢复旧的提交消息的漫长过程感到非常恼火c>和复制&粘贴过程。
有没有更好的解决方法?如果我包含多个提交,它将会如何呢?
编辑:稍微想一想,我想我在找什么for是一些
git reset
之后,这一行就可以做到:
git commit --reuse-message = HEAD @ {1}
甚至更短:
git commit -C HEAD @ {1}
您可以使用 @ user2718704 给出的其他选项。
As Git user I regular come across the situation, that I need to rework one or more commits in a way which do not fit into --amend
or rebase -i
with fixup commits. Typically I would do something like
git reset HEAD~1
# hack, fix, hack
git commit -a
# argh .. do I need to retype my message?
I take sensible composed commit messages quite serious. They typically contain larger text with references & justifications for the change. Until now, I'm quite annoyed on the lengthy process to recover my old commit message via an unsorted git reflog
, git log
and copy & paste process.
Is there a better to tackle this? And how would it, if my comprises more than one commit?
Edit: After a bit thinking about this I think what I'm looking for is some git stash-like functionality for commit messages where fixup/amend commits are not appropriate.
After a git reset
, this one-liner can do it:
git commit --reuse-message=HEAD@{1}
or even shorter:
git commit -C HEAD@{1}
You can use the other options given by @user2718704.
这篇关于Git:如何在'git reset'后重用/保留提交消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!