Search code examples
gitgit-cherry-pick

git cherry-pick built in option to keep original committer & author


Is there a built in option in git cherry-pick to keep the original Author & Committer? without using a script , especially needed when cherry-picking multiple commits.

i have found this script or this But both are over 2 years old

looking at the official documentation i did not see any option am i missing somthing?


Solution

  • Cherry-picking keeps the author by default anyway so there is nothing to do here.

    None of these commands let you keep the committer, but the committer name and email address come from your configuration, where you can lie if you wish, so:

    git -c user.name=bogus -c [email protected] cherry-pick <hash>
    

    will make the new commit under the given bogus name.

    Setting GIT_COMMITTER_DATE in the environment will override the current time as well. In fact, the environment variables are a general purpose mechanism—they're how git filter-branch does its thing. Hence the scripts that you found will work. Why are you worried about them being "over 2 years old" when Git itself is well over a decade old?