I am trying to use git commit -ac <commit_id>
to perform a new commit. However I see that the date and time is used for the new commit is that of the previous commit_id that I pass. Is there a way that it can use the current date and time?
Asked
Active
Viewed 65 times
1

user376507
- 2,004
- 1
- 19
- 31
2 Answers
2
--reset-author
option may do what you want, though it also resets author (if you were not the author of original commit) along with the commit timestamp. From git help commit
:
--reset-author
When used with -C/-c/--amend options, or when committing after a
conflicting cherry-pick, declare that the authorship of the
resulting commit now belongs of the committer.
This also renews the author timestamp.

ArtemB
- 3,496
- 17
- 18
0
You should be able to use the --date
flag.
--date=<date>
Override the author date used in the commit
This question shows the various date formats that you can use.
See the documentation for Git using git help commit
or at http://git-scm.com/docs/git-commit.
Also, I don't know what you're trying to achieve, but it you want to amend something that is wrong with the previous commit, you can do git commit --amend
to add/remove files or change the commit message if you haven't already pushed to any remotes.
-
I am trying to use the commit message from a previous commit I made, but when I use the `-c` option it was picking up the time and date of the original commit. I wanted it to pick the current time and date. Using `--reset-author` helped. – user376507 Feb 12 '14 at 21:59
-
Does the --date flag work? Seems strange to reset the author when all you want to do is reset the date. – jordelver Feb 12 '14 at 22:00
-
I did not try, it might work. But I do not want to specify the date explicitly. I wanted git to pick up the current date and time. – user376507 Feb 12 '14 at 22:31
-
Ok. I can understand that. – jordelver Feb 13 '14 at 09:49