如何将现有的 phabricator diff 一分为二?

How do I split an existing phabricator diff into two?

我有一个很大的代码差异需要审查,但它确实应该分成两个单独的差异。

每个差异都有很多提交,我可以找出哪一个(大部分)将提交字符串拆分为两个不同的任务,尽管更清晰的拆分将基于文件名(即 N 个文件是与 task-1 相关联,M 个其他文件与 task-2 相关联)。

有没有一种简单的方法可以做到这一点(通过提交或文件)?谢谢!

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

您应该为此目的使用补丁。

[git format-patch][1]

怎么做?

# 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

一个简单的解决方案(尽管我猜 codeWizard 的是更好的实践方案):

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