LinuxCommandLibrary

git-filter-repo

Fast, safe tool for rewriting Git repository history

TLDR

Remove file from history

$ git filter-repo --path [file.txt] --invert-paths
copy
Rename paths
$ git filter-repo --path-rename [old/path:new/path]
copy
Remove large files
$ git filter-repo --strip-blobs-bigger-than [10M]
copy
Analyze repository
$ git filter-repo --analyze
copy
Subdirectory to root
$ git filter-repo --subdirectory-filter [dir/]
copy

SYNOPSIS

git filter-repo [options]

DESCRIPTION

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.

PARAMETERS

--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.

CAVEATS

History rewriting destroys old commits. Requires fresh clone. Collaborators must reclone. Cannot be undone.

HISTORY

git filter-repo was created by Elijah Newren as the official replacement for git filter-branch, recommended by the git project.

SEE ALSO

git(1), git-rebase(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community