Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use future date while making git commits

Tags:

git

github

Is there any easy way to postpone GitHub commits?

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.

like image 739
Roman Pushkin Avatar asked Apr 28 '15 18:04

Roman Pushkin


People also ask

Can you change the date of a git commit?

Changing Git DatesYou can change the author date of a given commit by passing the --date flag to git commit .

How do I change a timestamp on a commit?

Just do git commit --amend --reset-author --no-edit . For older commits, you can do an interactive rebase and choose edit for the commit whose date you want to modify.

Should commit messages have periods?

In the same way you don't end an email subject line with a period, your Git commit subject line does not need a period either (plus with a 50 character limit you'll want to save every character you can).

Does git commit have timestamp?

There are actually two different timestamps recorded by Git for each commit: the author date and the commit date. When the commit is created both the timestamps are set to the current time of the machine where the commit was made.


1 Answers

You can use commit --date argument:

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

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: 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)"'

or

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

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

future-commit -m "future commit"
like image 61
Oleksandr Horobets Avatar answered Sep 17 '22 23:09

Oleksandr Horobets