pip install
They now have a python package that just works:
python3 -m pip install --user git-filter-repo
That method installs both the command line executable, and the Python library which you can use as shown here.
The executable is named git-filter-repo, and Git automatically picks up any executable in PATH with name git-* on calls like git *, which is how this works.
Ubuntu 23.04 onwards
On this Ubuntu version or the one before, Ubuntu started adding the supremely annoying (but somewhat understandable) "error: externally-managed-environment" message to any pip install which you can work around with either:
-
sudo apt install pipx
pipx install git-filter-repo
which places the executable at ~/.local/bin/git-filter-repo.
-
sudo apt install git-filter-repo
Related: https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-every-time-i-use-pip-3
I juts don't understand why pip stopped working with the good old --user, why do they keep changing the interface every two years!!!
Manual install
If for some reason you don't want to use pip, you can also just:
# Add to bashrc.
export PATH="${HOME}/bin:${PATH}"
mkdir -p ~/bin
wget -O ~/bin/git-filter-repo https://raw.githubusercontent.com/newren/git-filter-repo/7b3e714b94a6e5b9f478cb981c7f560ef3f36506/git-filter-repo
chmod +x ~/bin/git-filter-repo
Tested on Ubuntu 20.04, git-filter-repo ac039ecc095d.