thisago's blog


Create branch without history

Just learned the flag --orphan for git-checkout.

It lets you to create a branch untied from any parent, nice to create a public branch of a private repo.

git checkout --orphan public-branch-name

Source: Git Make new branch and push without history - Stack Overflow - Kiwix

You first need to create a new branch locally. By
default, this will use your current HEAD as a base.


Creating a branch without history

However, you can also create a new branch without any
history using git checkout --orphan  :

 # create a new branch without a history and check it out
 git checkout --orphan yournewbranch

 # edit your files

 # create a commit with these files
 git add .
 git commit
 # push that commit and create the remote branch
 git push -u your_remote yournewbranch