在进行git commit时使用将来的日期 [英] Use future date while making git commits

查看:63
本文介绍了在进行git commit时使用将来的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么简单的方法可以推迟GitHub的提交吗?

Is there any easy way to postpone GitHub commits?

如果这些提交将在1小时内一次又一次地执行,那也很好.
假设我有5次提交,那么第一个应该在上午10点出现,第二个应该在上午11点出现,第三次应该在中午12点出现,依此类推.

It would be also nice if these commits will go one after another in 1 hour.
Let's say if I have 5 commits, the first one should appear at 10am, second at 11am, third at 12pm and so on.

推荐答案

您可以使用commit --date参数:

You can use commit --date argument:

git commit -m "message" --date "Tue Apr 28 23:00:00 2015 +0300"

UPD: 还有一个很酷的脚本来改变旧的提交日期(您需要Perl来运行它): https://raw.githubusercontent.com/gitbits/git-shift/master /git-shift

UPD: there is also pretty cool script for shifting old commits date (you need Perl to run it): https://raw.githubusercontent.com/gitbits/git-shift/master/git-shift

perl git-shift +5h 2e6fd0a9dc98403c4fca638e411b3451cbc66a89

UPD2: 您可以创建自定义别名,以便自动转移所有新提交.为此,请将以下行放入〜/.bashrc文件

UPD2: You can create custom alias in order to shift all new commits automatically. In order to do that, put the following line into your ~/.bashrc file

alias future-commit='git commit --date "$(date -v +4H)"'

alias future-commit='git commit --date "$(date -d +4hours)"'

重新加载终端,现在您可以+4小时轮班提交:

reload terminal and now you will be able to commit with +4 hours shift:

future-commit -m "future commit"

这篇关于在进行git commit时使用将来的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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