I have an application code maintained in the Github repository. Now our requirement is to create the documentation for that application and save them under a separate branch in the same repository. I simply tried to create a new branch but it linked to the main branch. After googling it, I found an option --orphan to create branch with no parents.

This tutorial will help you to create a new empty branch in the Git repository.

Git Create Empty Branch

We can use --orphan command line option to create a new branch with no parents.

git checkout --orphan new-empty-branch 

The above command will create a new branch with no parents. Now, you can delete files from the working directory, so they don’t commit to a new branch.

git rm -rf . 

Now, you can add new files to this new branch, commit and push them up to the remote git repository.