I need to overwrite the date of the commit of git, all the documentation points to --date parameter, but then leaves one without a clue to the appropriate format. I've tried every permutation i can think of, and i'm getting "fatal: invalid date format:" error for each and every one.
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Is it possible to pass command-line arguments to @
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
Git 2.6+ (Q3 2015) add a new option.
See commit e4f031e (30 Jun 2015), and commit aa1462c, commit a5481a6, commit b7c1e11 (25 Jun 2015) by Jeff King (
peff
).(Merged by Junio C Hamano --
gitster
-- in commit d939af1, 03 Aug 2015)Davide Cavestro proposes in the comments the example:
Original answer (mid 2014)
The
--date
option (introduced in commit 02b47cd in Dec. 2009, for git1.7.0) uses the same format than forGIT_AUTHOR_DATE
, with date formats tested in commit 96b2d4f:There you can see the various format accepted:
Mon, 3 Jul 2006 17:18:43 +0200
2006-07-03 17:18:43 +0200
Mon Jul 3 15:18:43 2006
2006-07-03
(not in 1.9.1, works in 2.3.0)relative: see commit 34dc6e7:
raw: see commit 7dff9b3 (git 1.6.2, March 2009)
internal raw git format - seconds since epoch plus timezone
(put another way: '
date +"%s %z"
' format)Mon Jul 3 17:18:43 2006 +0200
ADTC asks and answers in the comments:
The date format is underdocumented at Documentation/date-formats.txt (
man git commit
), and very "humanishely" parsed.The only thing that works is reading the source under date.c and trying it out.
Points not mentioned by VonC on 2.3.0:
digits only are parsed depending on the number of digits:
2 digits: 19YY , for YY >= 73, current month, day and time. Errors or current date otherwise.
4 digits: YYYY , for YYYY >= 1973, <= 2099
> 8 digits up to some small limit (TODO which?): UNIX time (seconds since 1970)
@<digits> +0000
: UNIX time.This seems like the best way to enter UNIX times directly.
2**64 - 2 (TODO why not -1 ?) was the maximum value that does not lead to a commit error. The stamp is stored in a C long.
git log
shows very large values (somewhere around2^55
TODO where?) as 1970, even thoughgit cat-file -p HEAD
shows that the right number was stored, so it seems like a limitation of the date conversion.For anything larger than
2**63 - 1
, the largest positive signed long, trying to push to GitHub fails withdate causes integer overflow
. A commit at that date on GitHub (GitHub cannot show really large dates for some reason)VonC pointed that this is a shame as it blocks negative dates Is it possible to set a git commit to have a timestamp prior to 1970? which could be used to migrate older software to Git.
tea
: today at 17h :-)