Linux command
git-filter-repo 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
Remove file from history
git filter-repo --path [file.txt] --invert-paths
Rename paths
git filter-repo --path-rename [old/path:new/path]
Remove large files
git filter-repo --strip-blobs-bigger-than [10M]
Analyze repository
git filter-repo --analyze
Subdirectory to root
git filter-repo --subdirectory-filter [dir/]
说明
git filter-repo rewrites Git history with powerful filtering capabilities. It is the officially recommended replacement for the deprecated git filter-branch, offering significantly faster and safer history manipulation. The tool can remove files, rename paths, strip sensitive data, change authors, and restructure repositories. It prevents common mistakes that git filter-branch was prone to and operates much faster on large repositories.
参数
- --path _PATH_
- Filter specific paths.
- --invert-paths
- Invert path selection.
- --path-rename _OLD:NEW_
- Rename paths in history.
- --strip-blobs-bigger-than _SIZE_
- Remove large blobs.
- --analyze
- Generate analysis reports.
- --subdirectory-filter _DIR_
- Make subdirectory the root.
- --force
- Skip freshness checks.
- --help
- Display help information.
FAQ
What is the git-filter-repo command used for?
git filter-repo rewrites Git history with powerful filtering capabilities. It is the officially recommended replacement for the deprecated git filter-branch, offering significantly faster and safer history manipulation. The tool can remove files, rename paths, strip sensitive data, change authors, and restructure repositories. It prevents common mistakes that git filter-branch was prone to and operates much faster on large repositories.
How do I run a basic git-filter-repo example?
Run `git filter-repo --path [file.txt] --invert-paths` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --path _PATH_ do in git-filter-repo?
Filter specific paths.