I want to create a new GitHub branch, called release
.
This branch needs to be empty! However, there is an existing branch with x commits
--orphan
is good for creating an empty branch locally, however, in order to push it or interact with other branches, you will need a commit.
Creating a new commit on an orphan branch is not a good idea because you won't be able to interact with other branches. I.e.
git checkout --orphan test
git commit --allow-empty -m "init test branch"
git merge master
fatal: refusing to merge unrelated histories
Instead, you should prefer creating a new branch from the first commit of master. If the commit is not empty you can add an empty commit before the first one, as explained by @houtanb.