Background paper texture mobile
git

Fresh Branch Without Old History

Start a clean git branch with no commit history from the previous branch.

Author avatar

Peter Shaan

May 18, 2026


6 Views

Sometimes you want a fresh start — same codebase, zero history. This is useful when a branch has too many messy commits and you just want to ship clean.

Create an Orphan Branch

An orphan branch has no parent commits — it starts completely empty.

git checkout --orphan fresh-start

Remove All Tracked Files

git rm -rf .

Stage Everything Fresh

git add .

Make the First Commit

git commit -m "initial commit"

Force Push to Remote

git push origin fresh-start --force

If you want to replace main, switch the default branch in your repo settings first, then delete and re-push.


Alternative: Squash All Commits into One

If you want to keep the same branch name but clean up the history:

git checkout --orphan temp
git rm -rf .
git add .
git commit -m "initial commit"
git branch -D main
git branch -m main
git push origin main --force

Back to Notes