One problem when using Octopress(version “2.0”) is that: each time when doing deployment, a full copy of the website is added into the “master” branch as a new commit. If you have been updating the website hundreds of times like me, the “master” branch will have many commits and use much storage. As the content in the “master” branch is unnecessary to be version controlled, I always want to clear the “master” branch of “Octopress” to reduce the size of this repository.
Today I did some research and here is the solution(from here).
1 | cd ~/temp |
This solution first creates a new “orphan” branch named “temp” which has no history commits, then removes the “master” branch and renames the “temp” branch to “master”, finally pushes the new “master” branch to “github.com”. After these steps the “master” branch only has one commit and all the historical commits are cleared.
Note that, in this solution if you have a local working copy, after the remote “master” branch is cleared, running “git pull” on the local copy will get the following error:
1 | > git pull |
I didn’t find an elegant way to fix it. I just clone a brand new copy of the git repo to local environment again. The new cloned working copy doesn’t have this issue.
After this change, the storage used by my Octopress repository is reduced from 509MB to 147MB.
What about the storage used by the historical commits on “github.com”? I guess it will be garbage collected automatically.