Git create remote repository on push

There is currently no way to use git push to create a repository on the remote. The best you can do is write a one-liner script something like this:

#!/bin/bash
ssh $1 "git init --bare $2" &&
git push ssh://$1/$2

Hopefully you can ssh in; if you can’t, you could use some kind of filesystem access to just manually create the repo by dumping in the appropriate file/directory structure (maybe create it locally and copy). You might also create a named remote along the way.

This was actually one of the most requested features on the 2010 Git Survey – so maybe you’ll get your wish sometime in the next year!

Leave a Comment