I tried to initially do this using the perl based cj-git-filter-branch
tool from https://github.com/pflanze/chj-bin (which required ensuring Perl was viable and a few CPAN packages were installed) with a CLI invocation like:
~/source/chj/chj-bin/cj-git-filter-branch --remove-all-but-those-in ../keepers.txt -f
And a keepers.txt
like:
acceptance/tests/resource/scheduled_task/should_create.rb
acceptance/tests/resource/scheduled_task/should_destroy.rb
acceptance/tests/resource/scheduled_task/should_modify.rb
acceptance/tests/resource/scheduled_task/should_query.rb
lib/puppet/provider/scheduled_task/win32_taskscheduler.rb
lib/puppet/type/scheduled_task.rb
lib/puppet/util/windows/taskscheduler.rb
spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb
spec/unit/type/scheduled_task_spec.rb
But then ended up doing some additional massaging like
git filter-branch -f --prune-empty --parent-filter ~/source/puppetlabs-scheduled_task/puppet-code/rewrite_parent.rb
#!/usr/bin/ruby
old_parents = gets.chomp.gsub('-p ', ' ')
if old_parents.empty? then
new_parents = []
else
new_parents = `git show-branch --independent #{old_parents}`.split
end
puts new_parents.map{|p| '-p ' + p}.join(' ')