3

Is it possible to create a new Git repository without creating it first on http://gitlab.com? My intention is to init a local repository, do some work, add files to the index, commit and finally push it to the server without creating the new repository manually on gitlab.

Repository creation failed with an error message: GitLab: The project you were looking for could not be found. fatal: Could not read from remote repository.

when I finally do

git push origin --all 
1
  • 2
    I'm trying to envision how this would even work? So a git host should just assume, on seeing a push to an unknown URL, that the intent is to create a new repo? And if someone sends the wrong URL by mistake they just silently get a new repo and now have fractured history? And if someone doesn't check that a URL isn't already in use, they just accidentally dump content into an unrelated repository? Repo creation is a significant event that should require manual action that clarifies intent (and an interaction with the host site to ensure guidelines are followed) Commented May 3, 2017 at 13:10

2 Answers 2

1

Trying to answer the same question for myself (create a new gitlab repo from commandline and then push to it), I found this article Push to create a new project in GitLab's help pages. It worked for me running this command:

git push --set-upstream https://gitlab.example.com/myusername/nonexistent-project.git master

and then added the remote to the repo as prompted:

git remote add origin https://gitlab.example.com/myusername/nonexistent-project.git

(working for GitLab 10.5 and on)

Sign up to request clarification or add additional context in comments.

1 Comment

Actually this "Push to create a new project" GitLab's feature added in 2018 February ... almost a year after this question was asked.
0

I don't think most git hosting websites allows you to create repository automatically. You have to create it manually.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.