Apply a commit chunk by chunk

When I add a file to staging, I can

$ git add my_file -p

And select the chunks I want to stage.

  • Preparing a git commit messaging before committing?
  • How can I push a specific commit to a remote, and not previous commits?
  • What is the git commands to delete unwanted commits that haven't been pushed to the remote?
  • cherry-pick a commit and keep original SHA code
  • How to set git commit --author properly from rake running under LocalSystem account?
  • Cannot Commit to the SVN - CHECKOUT can only be performed on a version resource
  • Is there a way to merge/cherry-pick a commit and apply its diff chunk by chunk?

    Thanks

  • Dropbox > git commit
  • Git, get unchaged files between commits
  • How can I see all the files that were modified/added/removed in the last push received?
  • Godep with local packages
  • symbolic link to specific git reference
  • Xcode and Git Source Control : “The working copy XXXXX failed to commit files”
  • One Solution collect form web for “Apply a commit chunk by chunk”

    I’m not aware of a direct way to do this but here’s an indirect way.

    git cherry-pick -n <commit>

    Cherry pick the commit but tell git not to commit it (-n). The changes should now be in your working copy so you can do

    git checkout -p

    This will iterate over each chunk and ask if you want to discard it, say yes to any chunks you don’t want and no to chunks you want to keep.

    Git Baby is a git and github fan, let's start git clone.