Desired Solution: I want magit to make a commit with a datetime set to the time that I "create" the commit, not the time that I start the commit "creation" flow.
Background:
So committing in magit in general follows these steps:
S
Stages all files.c c
Initiates a commit, then write the message in the "commit buffer".C-c C-c
to actually create the commit.
The thing that surprises me is that the datetime of the created commit is actually the datetime that I pressed c c
, NOT the time that I pressed C-c C-c
. I find this very annoying as I am trying to be better about writing more detailed commits (often spending a few minutes on them). The date of the commit does not reflect when I actually created the commit, it instead reflects when I started the commit.
Details:
Why do I care about being off by a few minutes? Because I am recording videos as I work and would like to slice them at the commit points. However, the commit points are all a few minutes before the actual commit was made in the video. This is kind of annoying.
GIT_COMMITTER_DATE
and/orGIT_AUTHOR_DATE
environment variables is the only way I know. I'd usegit-commit-setup-hook
to set it up to current value. This isn't perfect and reasons are explained in the manual, but less messy than automatically amend each commit. – Muihlinn May 5 '20 at 7:55git commit
from the command line -- git will invoke whatever editor you have configured, and ultimately the commit timestamp will be the point at which you invoked the command, not the point at which you finished editing the message. Magit simply arranges (via itswith-editor
magic) that the editor invoked by git will be the Emacs instance you're using at the time; but it's still just callinggit commit
, and the commit timestamp is entirely subject to that. – phils May 5 '20 at 11:52git commit -m "<message>"
and so thought it was something being introduced by Magit. I do find the default behavior a bit funny. It is strange that the recorded "time" of something is actually before the commit finalized. However, I also recognize that the hash is partially time dependent, and how could you build the hash if you can't "freeze" the commit time? Seems a bit odd, but at the same time, I get it. Anyway, thank you for clarifying. – Stephen Cagle May 14 '20 at 4:08