You don't need to use a second repository - you can do commands like git checkout
and git commit
on a bare repository, if only you supply a dummy work directory using the --work-tree
option.
Prepare a dummy directory:
$ rm -rf /tmp/empty_directory
$ mkdir /tmp/empty_directory
Create the master
branch without a parent (works even on a completely empty repo):
$ cd your-bare-repository.git
$ git checkout --work-tree=/tmp/empty_directory --orphan master
Switched to a new branch 'master' <--- abort if "master" already exists
Create a commit (it can be a message-only, without adding any files, because what you need is simply having at least one commit):
$ git commit -m "Initial commit" --allow-empty --work-tree=/tmp/empty_directory
$ git branch
* master
Clean up the directory, it is still empty.
$ rmdir /tmp/empty_directory
Tested on git 1.9.1. (Specifically for OP, the posh-git is just a PowerShell wrapper for standard git.)