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.

  • Show the progress of commiting
  • What is the value of atomic commits in Subversion?
  • Changing git commit message after push (given that no one pulled from remote)
  • Add commits before root commit in Git?
  • How do I merge a single commit?
  • How do you move a commit to the staging area in git?
  • Is there a way to merge/cherry-pick a commit and apply its diff chunk by chunk?

    Thanks

  • git: use “commit --cleanup=whitespace” with “rebase --interactive”
  • Planning repository layout for git migration
  • GitHub for Mac crashes on open because of local repository issue
  • git fetch failed “refs/remotes/origin/pr/34 tracks both”
  • Commit a file to a Different Branch Without Checkout
  • Git reference conflicts between branches (unable to update local branch)
  • 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.