I stumbled upon a rather strange feature yesterday! It turns out it’s possible to push git repositories from the local computer to GitLab.com (I guess it works for self-hosted version of GitLab as well) without actually having to create the repository first on GitLab.com.

I normally create the upstream repository on GitHub or GitLab.com with a README file, clone it and commit changes from there. Or, I create create a first commit, and set upstream logic with git remote add origin git@gitlab.com:arunsathiya/repo.git before pushing using git push -u origin master.

Here, repo is the repository’s name/slug.

But, GitLab.com does not actually require the repository to exist online. Using git remote add origin git@gitlab.com:arunsathiya/repo.git on a repository pushes that to GitLab.com and automatically creats that non-existent repository online.

I reached out to their customer support team here and they confirmed that it’s a feature.

All you need is,

GitLab.com would create that repository for you online, and show this result,

Code references from the document linked earlier.

Published by Arun

Happiness Engineer, Automattic; Prev, Freshworks Inc