Назад | Перейти на главную страницу

ВНИМАНИЕ: в git-filter-branch есть множество ошибок, генерирующих искаженные перезаписи истории

Я хочу очистить большой файл из моего локального репозитория git (и, кстати, очистить мой репозиторий, чтобы уменьшить размер). Это мой баш:

#!/bin/bash
bigfile="/path_to_mygitproject/bigfile.tar.gz"
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch '"$bigfile"'' --prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch '"$bigfile"'' HEAD

Но теперь покажите следующее предупреждение:

WARNING: git-filter-branch has a glut of gotchas generating mangled history
     rewrites.  Hit Ctrl-C before proceeding to abort, then use an
     alternative filtering tool such as 'git filter-repo'
     (https://github.com/newren/git-filter-repo/) instead.  See the
     filter-branch manual page for more details; to squelch this warning,
     set FILTER_BRANCH_SQUELCH_WARNING=1.

Я всегда использовал этот bash, и у меня никогда не было проблем. До нынешнего момента. Думаю, что-то изменилось в git.

Я пытаюсь заменить "git filter-branch" на "git filter-repo", но получаю сообщение:

git: 'filter-repo' is not a git command. Look at 'git --help'.but

что мне исправить? Спасибо

Обновить:

Я сделал это но вроде все изменилось

wget https://raw.githubusercontent.com/newren/git-filter-repo/master/git-filter-repo -O /home/user/.local/bin/git-filter-repo
chmod +x /home/user/.local/bin/git-filter-repo

И замените в моем скрипте «git filter-branch» на «git filter-repo». Вне:

git-filter-repo: error: argument --prune-empty: expected one argument
git-filter-repo: error: unrecognized arguments: --index-filter git rm -r --cached --ignore-unmatch bigfile.tar.gz HEAD

Я проверил примеры и я добавляю "--prune-empty auto", но я не смог исправить свой скрипт, потому что я не знаю, какие будут альтернативы "--index-filter" или "--tag-name-filter" (кажется, их не существует)

git filter-repo --version
ffc6fa9265d8
git --version
git version 2.25.1

Обновить:

Мне удалось уменьшить размер моего репо с помощью команды:

git filter-repo --strip-blobs-bigger-than 10M

Но это неподходящий метод, так как я могу удалить другие файлы, размер которых превышает 10 МБ, и которые я не хочу удалять.

Решено!

git filter-repo --path bigfile.tar.gz --invert-paths

голосование близко