I want to be able to do this for a script. I'm essentially re-creating the entire version history of some code in Git - it currently uses a different version control system. I need the script to be able to add in the commits to Git while preserving the commit's original author (and date).
Assuming I know the commit author and the date/time the change was made, is there a Git command that allows me to do this? I'm assuming there is, because git-p4 does something similar. I'm just asking for the best way to do it.
Just to add to this: The
--author
option mentioned in the accepted answer will only override the author, not the committer information of the commit.That is the correct behavior in most cases, but if for some reason you need to manually override the committer information as well, use the
GIT_COMMITTER_NAME
andGIT_COMMITTER_EMAIL
environment variables (there is aGIT_COMMITTER_DATE
as well). See Git-Internals-Environment-VariablesThis will make the commit look like it was authored and committed by the specified user.
Check out the
--author
option forgit commit
:From the man page: