I have a feature branch in which I mistakenly committed a large image file, but then later deleted the file within the same feature branch. The branch was pushed up before the deletion (I don't think that matters). If I squash merge this branch into the main branch and delete the feature branch on merge, will the image file that was once in the feature branch but is no longer in either still contribute to bloat in the repository by way of its history?
Asked
Active
Viewed 158 times
0
-
1No it won't, but you may need to run `git gc` on your local repo to clean up before the image really disappears. – iBug Mar 08 '21 at 05:39
1 Answers
2
For a while, yes, but only until the garbage collection kicks in. The file is not part of any reachable commit so it will be deleted.

1615903
- 32,635
- 12
- 70
- 99
-
Thanks. And is my understanding of git correct that it is *because of the squash* that this is true? I.e., that I *need* to squash to take care of this bloat issue? – Faust Mar 08 '21 at 05:42
-
Yes - or some other measure that modifies the history so that the large file is not present in any commit, i.e. interactive rebase. – 1615903 Mar 08 '21 at 05:44
-
No, the squash is irrelevant to why the commits containing the file become unreachable. They are unreachable because you deleted the only branch name that pointed to them. – matt Mar 08 '21 at 07:57