修改时更新git commit author date [英] Update git commit author date when amending

查看:228
本文介绍了修改时更新git commit author date的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己经常修改我的提交。我不会这么做,因为我倾向于忘记我是这么做的,特别是当我想在离开之前或周末之前保存我所做的事情时,所以我做了一个草案承诺。唯一的问题是,当我修改提交时,它仍然设置为原始作者日期。是否有一个(简单的)方式来修改时更新它?

解决方案

您可以使用 - date 参数为 git commit 。因此,如果您想修改上次提交,并将其作者日期更新为当前日期和时间,则可以执行以下操作:

  git commit --amend --date =$(date -R)

code> -R 参数给 date 告诉它以RFC 2822格式输出日期,这是 git commit 理解的日期格式。)


I found myself amending my commits quite often. I don't stash so much because I tend to forget I did so, especially when I want to save what I did before I leave or before a weekend, so I do a "draft" commit. Only thing is, when I amend the commit, it is still set to the original author date. Is there a (simple) way to update it when amending?

解决方案

You can change the author date with the --date parameter to git commit. So, if you want to amend the last commit, and update its author date to the current date and time, you can do:

git commit --amend --date="$(date -R)"

(The -R parameter to date tells it to output the date in RFC 2822 format. This is one of the date formats understood by git commit.)

这篇关于修改时更新git commit author date的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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