-
Clone project
-
Checkout all branches that contain the files that should be moved
-
Delete the remote
-
Run the filter-branch command:
git filter-branch --tree-filter 'mkdir -p /path/to/tmp; mv * /path/to/tmp; mkdir subdir; mv /path/to/tmp/* subdir/' --tag-name-filter cat --prune-empty -- --all
- All files are first copied to a temporary dir and move from there to the new destination
- Existing tags are updated
- Empty commits are ignored
- The filters are applied to all branches
-
Add the remote
-
Push (force) all branches and tags back to remote:
git push -f --all git push -f --tags
Forked from fabiomaggio/git-filter-branch-move-files.md
Created
June 8, 2020 14:37
-
-
Save qcom/9a87927491f61dc5865ec6d532a4e526 to your computer and use it in GitHub Desktop.
Use git filter-branch to move all projects files to a subdir and rewrite all commits
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment