/docker-git-filter-repo

git-filter-repo utility

Primary LanguageMakefileMIT LicenseMIT

docker-git-filter-repo

A Docker Image with git-filter-repo integrated

Useful links

Build

Build the image or use latest from Docker Hub

# Using build.sh script
$ ./build.sh
# or manually
$ docker build -t qnimbus/docker-git-filter-repo .

Usage

Optionally, create shell alias for ease of use

git-filter-repo_func() {
  docker run --rm -v "${PWD}:${PWD}" --user "$(id -u):$(id -g)" --workdir="${PWD}" qnimbus/docker-git-filter-repo git filter-repo "$@"
}

alias git-filter-repo="git-filter-repo_func"

Optionally, create a git alias to check for deleted files

$ git config --global alias.deleted "log --diff-filter=D --summary"
# Usage:
$ git deleted

To view repository files in bare repository

$ git ls-tree --full-tree -r HEAD | more

Create a mirror clone

$ git clone --mirror <your repo> mirror_repo

Run the image and mount the cloned repo into it

$ docker run --rm -it -v ./mirror_repo:/repo qnimbus/docker-git-filter-repo --workdir=/repo /bin/bash

Run the desired commands

# Example which removes two paths
$ git filter-repo --invert-paths --path unneeded_path1 --path unneeded_path2
# Or a path-glob for multiple files
$ git filter-repo --invert-paths --path-glob '*.json'

Run the garbage collection on the git

$ git reflog expire --expire=now --all && git gc --prune=now --aggressive

Finally, push the repo

$ git push --no-verify --mirror