0

A feature request (tooBigFeature) has spiraled into a 100-commit, 50-file PR, which, at the end of review, engineering has decided it wants in 10 5-file PRs (tinyFeatureChunk-01, tinyFeatureChunk-02... etc) - all off a common single commit on our master branch chucknorrisbranch (which was just pulled into the tooBigFeature branch, of course) so that in case of emergency it can roll back smaller PRs.

Assume that all changes tooBigFeature are functionally independent, and that splitting will cause no problems aside from partial, error-free diminution of the feature's completeness in production.

How do I do this ? Are there any tools to do this ?

Sean Munson
  • 156
  • 9

1 Answers1

1

This seems like quite an annoying task to be asked to do but one approach would be to

  • git reset chucknorrisbranch to get all your work ready to be staged
  • 10 times repeat:
    • git checkout -b tinyFeatureChunk-0<index> chucknorrisbranch
    • git add <5 files>
    • git commit -m "Some message"

A quick Ruby script that would do the above might look like this

`git status --porcelain`.chomp.split("\n").each_slice(5).with_index { |lines, index|
  `git checkout -b tinyFeatureChunk-0#{index + 1} chucknorrisbranch`
  lines.each { |line| `git add #{line[3..]}` }
  `git commit -m "some message"`
}
Paul.s
  • 37,649
  • 5
  • 66
  • 85