Is it possible in git to create a new, empty remote branch without pushing?

As mentioned in the blog post "Start a New Branch on your Remote Git Repository":

  • Creating a Remote Branch
git push origin origin:refs/heads/new_feature_name
  • Make sure everything is up-to-date
git fetch origin
  • Then you can see that the branch is created.
git branch -r

This should show ‘origin/new_feature_name

  • Start tracking the new branch
git checkout --track -b new_feature_name origin/new_feature_name

So to declare a remote branch, even one which doesn't yet exist on the local repository, git push is mandatory.


git checkout --orphan new-empty-branch

Then

git rm -rf .

to remove all files from new branch.

Tags:

Branch

Git