Reputation: 2675
I wonder how would you create a commit in the past?
I've searched for it, and as far as I understand one can use git commit --date""
I would really appreciate if someone could clarify this and give an example of the date format.
Upvotes: 2
Views: 2050
Reputation: 1330102
Note that git 2.0.X/2.1 (Q3 2014) will accept more date format.
That means git commit --date=2.days.ago
will work! Easy to set a commit in the past.
See commit 14ac286 by Jeff King (peff
)
commit
: accept more date formats for "--date
"Right now we pass off the string found by "
--date
" straight to thefmt_ident
function, which will use our strictparse_date
to normalize it. However, this means obvious things like "--date=now
" or "--date=2.days.ago
" will not work.Instead, let's fallback to the approxidate function to handle this for us. Note that we must try
parse_date
ourselves first, even though approxidate will try strict parsing itself. The reason is that approxidate throws away any timezone information it sees from the strict parsing, and we want to preserve it. So asking for:
git commit --date="@1234567890 -0700"
continues to set the date in -0700, regardless of what the local timezone is.
Upvotes: 1
Reputation: 33794
For example --date="Wed Feb 16 14:00 2011 +0100"
From kernel.org:
DATE FORMATS
The GIT_AUTHOR_DATE, GIT_COMMITTER_DATE environment variables and the
--date
option support the following date formats:Git internal format It is , where is the number of seconds since the UNIX epoch. is a positive or negative offset from UTC. For example CET (which is 2 hours ahead UTC) is +0200.
RFC 2822 The standard email format as described by RFC 2822, for example Thu, 07 Apr 2005 22:13:13 +0200.
ISO 8601 Time and date specified by the ISO 8601 standard, for example 2005-04-07T22:13:13. The parser accepts a space instead of the T character as well.
source: http://www.kernel.org/pub/software/scm/git/docs/git-commit.html
Upvotes: 8