Skip to content

Instantly share code, notes, and snippets.

@ktaragorn
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktaragorn/1b5468843e587e818383 to your computer and use it in GitHub Desktop.
Save ktaragorn/1b5468843e587e818383 to your computer and use it in GitHub Desktop.
Rewrite history to move files from the root of the project into sub dir
files = Dir.entries(".")
sub_dir = "clowns_as_many"
(files - [".", "..", ".git", ".gitignore", "lib", ".DS_Store", "move.rb"]).each do |file|
cmd = "git filter-branch -f --tree-filter \'if [ -e #{file} ]; then mkdir -p #{sub_dir} && mv #{file} #{sub_dir}/; fi\' HEAD"
p cmd
system cmd
end
@ktaragorn
Copy link
Author

This is to move all files except those in the blacklist from the root dir to the dir clowns_as_many

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment