gitphabricatorarcanist

How do I split an existing phabricator diff into two?


I've got one big diff of code up for review, but it really should be split into two separate diffs.

There are many commits associated with each diff, and I could figure out which one (mostly) splits the string of commits into the two different tasks, although a cleaner split would be based on file names (i.e. N files are associated w/ task-1, and M other files are associated w/ task-2).

Is there a simple way to do this (either by commit or files)? Thanks!


Solution

  • Is there a simple way to do this (either by commit or files)? Thanks!

    You should use patches for this purpose.

    [git format-patch][1]
    

    How to do it?

    # first checkout the desired commit that you want to use
    # or stay on the desired branch itself
    git checkout commit_id
    
    # now create patch for the desired diff tree you want
    # This command will create a **single** patch file with all the diffs 
    # in the given range. (X commits back)
    git format-patch HEAD~X --stdout > patch_file.patch
    
    # or if you need the full branch history use the branch name
    git format-patch <branch name> --stdout > patch_file.patch