Hillary Sanders
Hillary Sanders

Reputation: 6047

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!

Upvotes: 3

Views: 2421

Answers (2)

CodeWizard
CodeWizard

Reputation: 142362

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

Upvotes: 4

Hillary Sanders
Hillary Sanders

Reputation: 6047

One simple solution (although codeWizard's I'm guessing is the better practice one):

get checkout mybranch
git rm --cached <filefornewbranch1>
git rm --cached <filefornewbranch2>
...
arc diff
git checkout -t -b newbranch
git add <filefornewbranch1>
git add <filefornewbranch2>
...
arc diff

Upvotes: 0

Related Questions