To rename a directory or file (I don't know much about complex cases, so there might be some caveats):
git filter-repo --path-rename OLD_NAME:NEW_NAME
To rename a directory in files that mention it (it's possible to use callbacks, but I don't know how):
git filter-repo --replace-text expressions.txt
expressions.txt
is a file filled with lines like literal:OLD_NAME==>NEW_NAME
(it's possible to use Python's RE with regex:
or glob with glob:
).
To rename a directory in messages of commits:
git-filter-repo --message-callback 'return message.replace(b"OLD_NAME", b"NEW_NAME")'
Python's regular expressions are also supported, but they must be written in Python, manually.
If the repository is original, without remote, you will have to add --force
to force a rewrite. (You may want to create a backup of your repository before doing this.)
If you do not want to preserve refs (they will be displayed in the branch history of Git GUI), you will have to add --replace-refs delete-no-add
.