Last active
January 5, 2016 14:42
-
-
Save juan-m-medina/90b0862989832476a4a0 to your computer and use it in GitHub Desktop.
Git single file Cherry Pick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I'd do it with cherry-pick -n (--no-commit) which lets you inspect (and modify) the result before committing: | |
git cherry-pick -n <commit> | |
# unstage modifications you don't want to keep, and remove the | |
# modifications from the work tree as well. | |
# this does work recursively! | |
git checkout HEAD <path> | |
# commit; the message will have been stored for you by cherry-pick | |
git commit | |
############################################### | |
# If the vast majority of modifications are things you don't want, instead of checking out individual paths (the middle step), you could reset everything back, then add in what you want: | |
# unstage everything | |
git reset HEAD | |
# stage the modifications you do want | |
git add <path> | |
# make the work tree match the index | |
# (do this from the top level of the repo) | |
git checkout . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment