Last active
April 24, 2022 23:35
-
-
Save evandrocoan/b965fc6c322ef83e717722967bc8bf7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Licensing | |
# | |
# Snippets | |
# Copyright (C) 2018 Evandro Coan <https://github.com/evandrocoan> | |
# | |
# OS ARQUIVOS NESTE REPOSITÓRIO SÃO FORNECIDOS "NO ESTADO EM QUE SE ENCONTRAM", SEM GARANTIA DE | |
# QUALQUER TIPO, EXPRESSA OU IMPLÍCITA, INCLUINDO, MAS NÃO SE LIMITANDO ÀS GARANTIAS DE | |
# COMERCIALIZAÇÃO, APTIDÃO PARA UM PROPÓSITO ESPECÍFICO E NÃO INFRACÇÃO. EM NENHUMA CIRCUNSTÂNCIA, OS | |
# AUTORES OU TITULARES DE DIREITOS AUTORAIS SERÃO RESPONSÁVEIS POR QUALQUER RECLAMAÇÃO, DANOS OU OUTRA | |
# RESPONSABILIDADE, SEJA EM AÇÃO DE CONTRATO, DELITO OU DE OUTRA FORMA, DECORRENTE, DESTE OU | |
# RELACIONADO COM DOS ARQUIVOS DESTE REPOSITÓRIO OU O USO OU OUTRAS NEGOCIAÇÕES NO MODELO E SOFTWARE. | |
# | |
Excluir arquivos de todas as commits. | |
Update to Use: | |
Download the tool from: https://github.com/rtyley/bfg-repo-cleaner | |
// Use this to replace things, remember to set up the 'replacements.txt' on the current folder, as the 'bfg.jar'. | |
java -jar bfg.jar --no-blob-protection --delete-files "{clear_cursors_carets.py,unittesting.json}" $name.git | |
java -jar bfg.jar --no-blob-protection --replace-text "replacements.txt" $name.git | |
java -jar bfg.jar --no-blob-protection --delete-folders "{source-csdm,source-orpheu}" $name.git | |
name=OperatingSystems && | |
base_url=https://github.com/evandrocoan && | |
repository=$base_url/$name && | |
git clone --mirror $repository && | |
java -jar bfg.jar --no-blob-protection --delete-files "{clear_cursors_car1ets.py,unittesting.json}" $name.git && | |
cd $name.git && | |
git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' HEAD && | |
git reflog expire --expire=now --all && git gc --prune=now --aggressive | |
git push origin --force | |
java -jar bfg.jar --no-blob-protection --delete-files "*.{pdf,cdr,eps,jpg}" abntex2-ufsc.git | |
java -jar bfg.jar --no-blob-protection --delete-folders "{Figuras-Fonte,Figs-Source}" abntex2-ufsc.git | |
git filter-branch --index-filter \ | |
'git rm --cached --ignore-unmatch Grafo.java -f' | |
Excluir pastas (-r -f), arquivos e commits vazias. | |
git filter-branch --force --index-filter \ | |
'git rm --cached --ignore-unmatch "addons/amxmodx/source-csdm" "README.md" -r -f' \ | |
--prune-empty --tag-name-filter cat -- --all | |
Excluir commits vazias. | |
git filter-branch --commit-filter 'git_commit_non_empty_tree "$@"' HEAD | |
Para finalizar: | |
git push origin --force --all && \ | |
git push origin --force --tags | |
# To fetch only tags: (http://stackoverflow.com/questions/1204190/does-git-fetch-tags-include-git-fetch) | |
git fetch <remote> 'refs/tags/*:refs/tags/*' | |
https://help.github.com/articles/remove-sensitive-data/ | |
Tell your collaborators to rebase, not merge, any branches they created off of your old (tainted) repository history. One merge commit could reintroduce some or all of the tainted history that you just went to the trouble of purging. | |
After some time has passed and you're confident that git filter-branch had no unintended side effects, you can force all objects in your local repository to be dereferenced and garbage collected with the following commands (using Git 1.8.5 or newer): | |
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin | |
git reflog expire --expire=now --all | |
git gc --prune=now | |
Counting objects: 2437, done. | |
Delta compression using up to 4 threads. | |
Compressing objects: 100% (1378/1378), done. | |
Writing objects: 100% (2437/2437), done. | |
Total 2437 (delta 1461), reused 1802 (delta 1048) | |
Note that you can also achieve this by pushing your filtered history to a new or empty repository and then making a fresh clone from GitHub. | |
http://stackoverflow.com/questions/1029969/why-is-my-git-repository-so-big/1036431#1036431 | |
http://stackoverflow.com/questions/43727619/how-to-display-file-sizes-using-milhar-separation-on-this-git-script | |
TO FIND BIG FILES ON THE REPOSITORY. | |
Some scripts I use: | |
ListBigFilesOnTheGitHistory.txt | |
git-fatfiles: | |
git rev-list --all --objects | \ | |
sed -n $(git rev-list --objects --all | \ | |
cut -f1 -d' ' | \ | |
git cat-file --batch-check | \ | |
grep blob | \ | |
sort -n -k 3 | \ | |
tail -n40 | \ | |
while read hash type size; do | |
size_in_kibibytes=$(echo $size | awk '{ foo = $1 / 1024 ; print foo "KiB" }') | |
echo -n "-e s/$hash/$size_in_kibibytes/p "; | |
done) | \ | |
sort -n -k1 | |
... | |
89076 images/screenshots/properties.png | |
103472 images/screenshots/signals.png | |
9434202 video/parasite-intro.avi | |
git-eradicate (for video/parasite.avi): | |
git filter-branch -f --index-filter \ | |
'git rm --force --cached --ignore-unmatch video/parasite-intro.avi' \ | |
-- --all | |
; | |
rm -Rf .git/refs/original && \ | |
git reflog expire --expire=now --all && \ | |
git gc --aggressive && \ | |
git prune | |
Note: the second script is designed to remove info from Git completely | |
(including all info from reflogs). Use with caution. | |
http://stackoverflow.com/questions/1904860/how-to-remove-unreferenced-blobs-from-my-git-repo | |
git tag | xargs git tag -d && \ | |
git remote rm origin && \ | |
rm -rf .git/refs/original/ .git/refs/remotes/ .git/*_HEAD .git/logs/ && \ | |
git for-each-ref --format="%(refname)" refs/original/ | xargs -n1 --no-run-if-empty git update-ref -d && \ | |
git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 \ | |
-c gc.rerereunresolved=0 -c gc.pruneExpire=now gc "$@" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment