Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT_COMMITTER_DATE not recognized

Tags:

git

github

gitlab

This is probably an extremely simple question but I'm trying to modify the date of a Git commit but whenever I try to modify the Git environment variables GIT_COMMITTER_DATE or GIT_AUTHOR_DATE I get this message.
When I type git var -l they don't show up either.
Do I have to add those variables myself?

C:\Users\MolinaBA\Desktop\MCPInfoGitMigrationTest>GIT_COMMITTER_DATE="12/12/12 4:40p +0000" git commit --amend --no-edit

'GIT_COMMITTER_DATE' is not recognized as an internal or external command,
operable program or batch file.
like image 534
molinab297 Avatar asked Jun 17 '17 15:06

molinab297


2 Answers

You need to first set the GIT_COMMITTER_DATE variable and then try git commit --amend. Shown below:

> set GIT_COMMITTER_DATE="12/12/12 4:40p +0000"
> git commit --amend --no-edit

Similar step for GIT_AUTHOR_DATE.

> set GIT_AUTHOR_DATE="12/12/12 4:40p +0000"
like image 89
nitishagar Avatar answered Sep 28 '22 01:09

nitishagar


If you are not using bash, you can set the variable just for this command with:

cmd /v /c "set GIT_COMMITTER_DATE=12/12/12 4:40p +0000&& git commit --amend --no-edit"

Note the lack of space before the &&. That is important or the value would have an extra space.

That way, you don't have to unset those variables once you are done using them got the commit --amend.
If you use the other answer, at least unset those variables:

set GIT_COMMITTER_DATE=
set GIT_AUTHOR_DATE=

Or any other git commit would use those dates!

But with the cmd /v /c "...", you limit the variable to that command. It does not persist in your CMD session.

like image 41
VonC Avatar answered Sep 28 '22 02:09

VonC