Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

You can create an empty new branch with the --orphan option to the git checkout command.

$ git checkout --orphan <branch name>

By the above command, you will be able to create a new branch and directly checkout to the new branch. It will be a parentless branch.

Now the empty branch is created locally, you have to push this to the remote server. If you have files in your working directory you can remove them with the rm command as shown below.

$ git rm -rf .
$ git commit --alow-empty -m "Initial commit"
$ git push origin <your empty branch name>

If you want to merge another branch, use the --allow-unrelated-history option to force the merge into the empty branch.

$ git merge --allow-unrelated-history <branchName>

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.