How do I cherry-pick the changes to only one file from a commit?

  1. First, find the commit hash you want to cherry-pick from
  2. Use this command:
git checkout <commit_hash> -- path/to/file

This will:

  • Take the version of the specified file from the commit you want
  • Stage those changes in your current branch
  • You can then commit these changes normally with git commit

Alternative method using git show:

git show <commit_hash>:path/to/file > path/to/file

Sign in to enable bookmarking, reminders, progress-tracking and more...