Git:如何在'git reset'后重用/保留提交消息? [英] Git: How to reuse/retain commit messages after 'git reset'?

查看:171
本文介绍了Git:如何在'git reset'后重用/保留提交消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

或<$ c $ c> rebase -i 带修复提交。通常我会做类似于

  git reset HEAD〜1 
#hack,fix,hack
git提交-a
#argh ..我需要重新键入我的消息吗?

我认为合理的组合提交信息非常严重。它们通常包含带有参考文献<改变的理由。直到现在,我对通过未分类的 git reflog git log 和复制&粘贴过程。



有没有更好的解决方法?如果我包含多个提交,它将会如何呢?



编辑:稍微想一想,我想我在找什么for是一些 stit 式的功能,用于提交消息,其中修复/修改提交不合适。 解决方案

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 -iwith 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 logand 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屋!

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