Creating an empty git branch and pushing it remotely

Say you wanted to create an empty branch of an existing git repository.  That is a new branch with no history, say to track your project docs.

Be sure that you don’t have any pending changes in your workspace before executing these commands.

$ cd ~/my-git-repo
$ git symbolic-ref HEAD refs/heads/docs
$ git rm –cached -r .
$ rm -fr *
$ git commit –allow-empty -m “Initialized docs branch.”
$ git push origin docs

Comments are closed.