(Git) Only cherry-pick a subset of files from a commit
- Use
git cherry-pick -n <COMMIT_SHA1>
to load all changes in the commit but only as staged (i.e. not committed to the current branch)-n
:--no-commit
- Unstage all the unnecessary file changes
- If only very few files are desired, then run
git reset HEAD
to unstage all changes, then re-stage only the desired files
- If only very few files are desired, then run
- Commit the staged files
Reference:
Written on February 25, 2021