With branches! Specifically, orphan branches1:
$ git init foo.ca && cd foo.ca
$ git commit --message "Initial commit" --allow-empty
$ git switch --orphan=api
$ git log
fatal: your current branch 'api' does not have any commits yet
This is useful, for example, if you have a private repository on Github.com with many members and don’t want to invite them to (or manage) (or pay for) 8 individual subdomain repositories as well.
I prefer to use the form main-<orphan>
for branch names. It keeps important
branches grouped together in lists and makes it easy to reference parents in
working branch names:
$ git switch --orphan=main-blog
$ git commit --message="Initial commit for blog.foo.ca" --allow-empty
$ git switch --create=blog/feature/comments
$ git branch --verbose
* blog/feature/comments 5093124 Initial commit for blog.foo.ca
main 6c6c484 Initial commit
main-blog 5093124 Initial commit for blog.foo.ca
-
git switch
is relatively new, you can also usegit checkout --orphan
. ↩︎