Install into PATH
e.g. $HOME/bin/
as "git-filter-mv" and chmod a+rx git-filter-mv
It works with any special characters in filenames like tabs and linefeeds. It works with empty commits.
Based on example from git-filter-branch
manpage.
If you want to print debug messages, use STDERR e.g. print STDERR "File: $_\n";
Examples:
git filter-mv 's!^!subdir/!'
➜ moves all files to a subdirectory "subdir/" in all commits of the current branch
git filter-mv 's!^source/!src/!'
➜ moves all files in "source/" to "src/" in all commits of the current branch
git filter-mv 's!^foo/bar.txt!foo/barbar.txt!'
➜ renames foo/bar.txt to foo/barbar.txt directly below the repository root in all commits of the current branch
git filter-mv 's!(^|/)bar.txt!$1barbar.txt!'
➜ renames bar.txt to barbar.txt in any directory in all commits of the current branch
Works like a charm. This was the only script that finally worked for me. I would also add
--tag-name-filter cat
to migrate tags and--prune-empty
to thegit filter-branch
command