My project has become unbearable big. In the past I accidentally included a lot of binary data as images and now it is bloated.

The following command will show how big some of the blobs are:

du -sh * .??* | sort -rh

221M	.git
76M	_site
50M	vendor
48M	assets
22M	images
1,7M	.jekyll-cache
696K	_posts
136K	_koines
72K	_includes
44K	_sass
32K	pages
32K	_layouts
16K	CHANGELOG
12K	bin
8,0K	README.md
8,0K	hooks
8,0K	_data
8,0K	css
8,0K	_categories
8,0K	.bundle
4,0K	index.html
4,0K	.gitlab-ci.yml
4,0K	.gitignore
4,0K	Gemfile.lock
4,0K	Gemfile
4,0K	docker-compose.yml
4,0K	_config.yml
4,0K	_config_dev.yml
4,0K	category.md
4,0K	404.html

I am thinking to shrink it down. There are several methods but I found this one the most efficient. I plan to reset the git history while keeping only the latest commit.

I create a new branch (new-master) that has no previous history, making it a fresh start.

git checkout --orphan new-master

I excluded the images from my portfolio in .gitignore

_site
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor
images/works

Now I stage and commit:

git add . && git commit -m "Initial commit with cleaned history"

I check out the history:

git log -2

commit 2688e01e5c1e063a1aef70a6000442a77c7599b7 (HEAD -> new-master)
Author: jazio <farcaso@gmail.com>
Date:   Fri May 2 01:00:48 2025 +0200

    Initial commit with cleaned history

Deletes the old master branch since it still holds the previous commit history.

git branch -D master

Deleted branch master (was 57231a9)

Now I rename the new-master in master

git branch -m master

How many local branches do I have?

git branch
* master

Time for push ups.

Remote branch is protected, git won’t allow you to force push (–force). I use --force-with-lease This ensures you only overwrite your own changes, preventing accidental data loss if others have updated the branch.

git push --force-with-lease origin master