, a 1-minute read
a branch with no past
git can start a branch with no history at all: for a built site, docs or assets that live in the same repo as the code but share nothing with it.
Every branch starts from a commit and carries all the history before it. Sometimes you want one that doesn't: a gh-pages branch for a built site, or a branch of assets that has nothing to do with the code.
git switch --orphan site
git commit --allow-empty -m "start the site"
git push -u origin sitegit switch --orphan makes a branch with no parent. The index starts empty and the files git tracks leave the working tree; the files it doesn't track stay where they are, so look at git status before you add everything.
The older way is git checkout --orphan, which keeps every file staged as it was. Its recipe has one more step:
git checkout --orphan site
git rm -rf .
git commit --allow-empty -m "start the site"The two branches now share nothing, not even a first commit: git merge-base main site finds no common ancestor, and merging one into the other takes --allow-unrelated-histories.
First published on my wiki, 12 April 2025; rewritten here, 25 November 2026. The original, on my wiki