When using git push
, must the destination repository already exist?
If the destination repository doesn't exist, how can I create it from my local machine?
When using git push
, must the destination repository already exist?
If the destination repository doesn't exist, how can I create it from my local machine?
The repository must exist. It's an issue of security. A repository must be created by someone with the correct permissions on the server side. Once the repository exists, you will usually have permissions to create new branches within it though.
I know of two ways to set up a repo on a remote machine. The simplest is to SSH in and make either init or clone a repo. If you do not have permission to do this, I'd ask the admin if the machine to do it for you.
For most servers or git hostings you must create a repository in advance before pushing. But there are a few clients or servers that can create repository on push.
I've heard that Github Desktop (a client for Github) can create a repository on push though I cannot find it in the docs.
Also if you want to create a repository at Github and don't want to use a web browser you can create a repository using Github API. To simplify things I recommend to use a command line wrapper for the API like hub.
Gitlab can create a repository on push.
Gitlab also has API and a lot of command-line wrappers. git repo works with Github, Gitlab and Bitbucket.