DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far...

Welcome! This is a Q&A website for computer programmers and users alike, focused on helping fellow programmers and users. Read more

What are you stuck on? Ask a question and hopefully somebody will be able to help you out!
+1 vote

How do I create a new branch which is not based on any other branch history? Basically an empty branch, with an empty working directory, not derived from any previous commits.

edited by

1 Answer

0 votes

You can create so-called "orphan" branches that have a disconnected history with

git switch --orphan <branch-name>


git checkout --orphan <branch-name>

The difference between the two is that git switch will remove all the tracked files, whereas git checkout will not. In the latter case if you want to remove all the files from the index and the working tree, you will have to run git rm -rf .

Contributions licensed under CC0