Cherry-pick changes from just one file

Once you've found the commit hash you want to cherry-pick from, you use this command:

This will:

  • Grab the content of the specified file from the specified commit
  • Stage those changes in your current branch
  • You can then commit these changes normally with git commit

Alternatively, you can obtain the content of that file as it was in that commit with git show:

And send it to a new file:

git show <commit>:<pathname> > path/to/file

Welcome to GitExamples!

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