Skip to content

Instantly share code, notes, and snippets.

@iainmerrick
Created May 6, 2024 22:05
Show Gist options
  • Save iainmerrick/d2a8480a693ae6b7de6053e5ecd72f53 to your computer and use it in GitHub Desktop.
Save iainmerrick/d2a8480a693ae6b7de6053e5ecd72f53 to your computer and use it in GitHub Desktop.
Cherry-pick git commit including all metadata
#!/bin/bash
export GIT_AUTHOR_NAME=`git show --quiet --format="%an" $1`
export GIT_AUTHOR_EMAIL=`git show --quiet --format="%ae" $1`
export GIT_AUTHOR_DATE=`git show --quiet --format="%ad" $1`
export GIT_COMMITTER_NAME=`git show --quiet --format="%cn" $1`
export GIT_COMMITTER_EMAIL=`git show --quiet --format="%ce" $1`
export GIT_COMMITTER_DATE=`git show --quiet --format="%cd" $1`
git cherry-pick -n $1
git commit -n -C $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment