Aamir Shaikh
Aamir Shaikh

Reputation: 403

How to remove my local branch history without affecting the master

I created a branch from the master, and have been adding and deleting a large number of binaries into the branch, As a result, the repo size has bloated to thrice its original size. I have removed the binaries and deleted the branch but the repo size does not change. How can i minimize the repo size?

Upvotes: 1

Views: 68

Answers (1)

quadroid
quadroid

Reputation: 8940

If you delete a Branch in git only the named ref is removed, the commits which store the source are still around and can viewed with git reflog or restored (as described here). Therefore deleting a branch does not free any diskspace (out of a view kb's). This commits are called dangling commits because there is no branch / tag that references the objects. To make git clean up this stuff call

git reflog expire --expire-unreachable=now --all
git gc --prune=now

This does of course only work if you have no branch referencing the commits containing the binary. And this does aswell destroy the reflog - making it impossible to restore currently deleted commits and branches.

Take a look at this Answer https://stackoverflow.com/a/4528593/2250672

Upvotes: 2

Related Questions