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.

  • What should be in a first commit?
  • How to pick a commit in sub-branch and merge it into main branch?
  • How to find out the space requirements of files to be committed?
  • Git is failing to Stage, or commit with SourceTree in a Windows network environment
  • How can I fix a reverted git commit?
  • Do you push every single commit?
  • Is there a way to merge/cherry-pick a commit and apply its diff chunk by chunk?

    Thanks

  • `git add` doesn't add files to track on Windows
  • code share between web app and cordova app
  • Why does use of multiDexEnabled (true) allow the app to build but constantly crash?
  • Git shows two branches in remote
  • Git: Recognize/identify version(s) of untracked copy / match to according commit(s)
  • Number of commits in a git repository
  • 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.