N
N
newitem2021-10-20 10:04:42
git
newitem, 2021-10-20 10:04:42

How to compress a .git folder?

The .git folder has grown to 5GB.
I want to reduce its size, because. can't clone properly.
Did:

git repack -a -d --depth=250 --window=250
git clean -d -f -i
git remote prune origin

But this did not bring results.
How to reduce it? Or how to delete commits older than 30 days for example? Is it possible?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Saboteur, 2021-10-20
@saboteur_kiev

1. git keeps all history. But the built-in garbage collector can remove commits that are not tied to any branch. So to start:
* Remove unnecessary strums.
* Run "git gc --aggressive --prune" after removing the branches.
2. Then you need to figure out what is taking up space for you. If you cram large files into your git repo and they are present in the active branch, then there is no way to delete them. More precisely, you can try to delete the files themselves manually or with the help of bfg-repo-cleaner, but you need to synchronize this with all participants. If you have a local git repo and no one uses it, it's easier. But at the same time, you break commits - it will no longer be possible to roll back to them.
3. Finally, you should spend an evening and read about git-flow, or even watch 3-4 YouTube videos from different authors that show different workflows with git. There you will understand why and why people use rebase, squash, why they delete unnecessary branches and keep dev / master in good condition when there are no intermediate commits with a commit message like "typo" "forgot" "still" and similar garbage. And the git repo takes up minimal space.

R
Roman Kitaev, 2021-10-20
@deliro

https://rtyley.github.io/bfg-repo-cleaner/
https://git-lfs.github.com/ (migrate)

P
paran0id, 2021-10-20
@paran0id

Do you keep Binari? Or download the dependency libraries using git add . do you add every time? Find out what's eating up space, set up gitignore, read up on git lfs.

G
Griboks, 2021-10-20
@Griboks

No way. Git was invented for other purposes. Therefore, all you can do is delete the history, or even easier, re-create the repository

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question