git gc --aggressive --prune = all no elimina el archivo grande del repositorio
Hay muchas preguntas SO con respecto a "cómo eliminar un archivo grande agregado accidentalmente del repositorio", muchas de ellas sugieren usargit gc
mando. Sin embargo, me parece que no funciona y no sé qué está pasando mal.
Esto es lo que he hecho:
$ git init
Initialized empty Git repository in /home/wzyboy/git/myrepo/.git/
$ echo hello >> README
$ git add README
$ git commit -a -m 'init commit'
[master (root-commit) f21783f] init commit
1 file changed, 1 insertion(+)
create mode 100644 README
$ du -sh .git
152K .git
$ cp ~/big.zip .
$ git add big.zip
$ git commit -a -m 'adding big file'
[master 3abd0a4] adding big file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 big.zip
$ du -sh .git
77M .git
$ git log --oneline
3abd0a4 adding big file
f21783f init commit
$ git reset --hard f21783f
HEAD is now at f21783f init commit
$ git log --oneline
f21783f init commit
$ git gc --aggressive --prune=all
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), done.
Total 6 (delta 0), reused 0 (delta 0)
$ git gc --aggressive --prune=now
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), done.
Total 6 (delta 0), reused 6 (delta 0)
$ du -sh .git
77M .git
$ git version
git version 2.2.2
En la salida de la consola anterior, creé un nuevo repositorio de git, agregué un pequeño archivo de texto y el.git
El directorio tiene un tamaño de 152K, hasta ahora todo bien. Luego agregué un archivo grande en el repositorio y el directorio se hincha a 77M. Sin embargo, después de intentar eliminar el archivo grande (git reset --hard
ogit rebase -i
), No puedo recuperar el espacio en disco reclamado por el archivo grande, no importa cómo lo ejecutegit gc
con diferentes opciones
¿Alguien podría decirme por qué?git gc
no funciona en mi caso? ¿Qué debo hacer para recuperar el espacio en disco? ¿Es posible recuperar el espacio en disco usandogit gc
en lugar degit filter-branch
?
Gracias.