Skip to content

Instantly share code, notes, and snippets.

@mitrofun
Forked from bendasvadim/remove-from-git-index.txt
Created September 2, 2020 16:35
Show Gist options
  • Select an option

  • Save mitrofun/503d5c2c373b6a349817c30ef3c84fd2 to your computer and use it in GitHub Desktop.

Select an option

Save mitrofun/503d5c2c373b6a349817c30ef3c84fd2 to your computer and use it in GitHub Desktop.
GIT. Как полностью удалить файл из истории
1. Нужно найти все коммиты, которые изменяли файл:
git log --pretty=oneline --branches -- BIGFILE.ZIP
2.1 Удалить ссылки на файл из всей истории коммитов, начиная с последнего (пусть, хеш последнего коммита - 6df7640):
git filter-branch --index-filter 'git rm --cached BIGFILE.ZIP --ignore-unmatch' --prune-empty --tag-name-filter cat -- --all
2.2 Удалить ссылки на каталог из истории коммитов:
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch BIG/DIR' --prune-empty --tag-name-filter cat -- --all
3. Отправляем изменения на сервер:
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment