3

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!

Hillary Sanders
  • 5,778
  • 10
  • 33
  • 50

2 Answers2

4

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
Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
0

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
Hillary Sanders
  • 5,778
  • 10
  • 33
  • 50