I have been using commands like:
git filter-branch --index-filter \
'git ls-files -s | sed "s_subdir/__" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"' HEAD
to move a directory tree from a subdirectory "subdir" to the top-level. In order to clean up the repo after a different and also successful filter-tree, I've tried using:
git filter-branch --tag-name-filter cat -- --all
git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' HEAD
git reflog expire --all --expire=now
git gc --prune=now --aggressive
This mixes a couple of recommendations from hereabouts. However, after doing this filter-branch no longer works:
Rewrite 07436df7a2795910fb0b718d1a1b84e195cfabea (1/113) (0 seconds passed, remaining 0 predicted) mv: cannot stat ‘somepathhere/.git-rewrite/t/../index.new’: No such file or directory
index filter failed: git ls-files -s | sed "_subdir/__" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
I'm am not at all clear why this should be or which of the 'voodoo' clean up commands I used was responsible. Obviously some knowledge is missing from my git-fu. Can someone suggest what that could be?