Can you import a repository without having to create it first via the GOGS UI



I have just set gogs up and I have a number (> 20) of local git repositories that I want to import into gogs. I’d prefer to be able to import all these repositories via the command line (that way I can script something up). However if I do the following I get the following errors:

$ cd myoldrepo
$ git remote add origin http://mygogs:3000/hairy/MyRepo.git
$ git push origin -u master
fatal: repository ‘http://mygogs:3000/hairy/MyRepo.git’ not found

Does a repository need to be initially created via the gogs ui before you can import an existing repo into the gogs repository or can you import the local git repository directly into gos via the command line? Thanks.

Sorry if this is an obvious question but searching on google doesn’t seem to provide any definitive answer to it.




You can create the repo via the API first


Gogs has a few moving parts to worry about. The repo needs to be listed in the database before you’ll be able to push or work with it.

Gogs also adds some pre and post commit hooks to its bare repos. I made a new repo is gogs to see what it wants and then move those into my repos.

Here’s some info on how I imported my 150 repos from gitolite into gogs.