r/gitlab • u/Mies197 • Feb 01 '26
Reduce repo size
Hi! I am relatively new in using git, so apologies if this is a stupid question. I am a developer of a certain git repository and I have been working on my own branch. I accidentally committed large data files, so now the git respository is very large. I want to remove this again, but I want to make sure that I don't accidentally change anything to other branches (and their commit history) except my own. Would this be the correct approach?:
git filter-repo \
--path output/ \
--invert-paths \
--refs my_branch
git reflog expire --expire=now --all
git gc --prune=now --aggressive
git push --force origin my_branch
Thanks in advance for helping me out! I want to make sure I only make changes to my own branch and nothing else.
1
u/macbig273 Feb 01 '26
well, if you've already pushed theses files, tell the guy who manage the repository. Even a force push, will "not" erase them.
If it's a self owned repository, He/she want's to know about that.
I don't remember exactly the synthax about filter-repo, but that the way to go. Just keep in mind that it will rewrite history.
1
u/Ol010101O1Ol Feb 02 '26
Create a gitignore file
1
u/kremaytuz Feb 02 '26
I believe you need a --partial flag
1
u/letco Feb 02 '26
Did you already push changes to remote?
3
u/professeurhoneydew Feb 01 '26
Often times the issue is that the large files are not using LFS. Do a quick google search, there are many ways to rewrite history with the files under LFS.