1

Whenever I start a new project I add it to my Gitlab VCS (on-premise):

git init
git add .
git commit -m "Commit message"
git remote add origin git@git.example.com:foo.git
git push --set-upstream origin master

This results in:

Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 5.65 KiB | 2.82 MiB/s, done.
Total 7 (delta 0), reused 0 (delta 0)
remote:
remote: The private project foo was successfully created.
remote:
remote: To configure the remote, run:
...blah blah blah

However, this creates a private project. I can create projects in the web GUI; this respects the setting that I want new projects to default to internal (Admin > Settings > General > Visibility and access controls > Default project visibility).

I was wondering; is it possible to create a project as above, from the terminal, and specify the visibility (any one of private, internal or public)?

1 Answer 1

3

Official docs say's no. Project's created from command line always set to Private by default.

https://docs.gitlab.com/ee/gitlab-basics/create-project.html#push-to-create-a-new-project

If you have access rights to the associated namespace, GitLab will automatically create a new project under that GitLab namespace with its visibility set to Private by default (you can later change it in the project’s settings)

You can change project level from UI or using Gitlab API.

6
  • This is correct. The reason is for security. Pushing to create a new project is easy, which also means it can potentially be done accidentally if a user mistypes the Git remote URL. As such, it's safest to create as private and then allow users to change visibility later. Aug 7, 2019 at 16:13
  • @DrewBlessing That was already clear from the documentation (though I'm not sure where you got the reason from; is it your own drawn conclusion or do you have a source?). However, I feel that, when I specify, for example, say a --yesimsuremakeitpublic argument to the git push command your reason goes out the window. There's lots of commands that have a -y ("answer yes to all questions") or -f ("force") or similar argument to acknowledge you're about to do something 'dangerous' but don't ask questions and continue without intervention. I don't see why git would be an exception?
    – RobIII
    Aug 10, 2019 at 0:39
  • 1
    I work for GitLab :) That was my recollection. I think your suggestion makes sense, and would be a good addition. Can you create a feature proposal for that, please? gitlab.com/gitlab-org/gitlab-ce/issues Aug 12, 2019 at 16:29
  • Would you mind giving an overview of doing this via the API? Frankly it seems impossible without jumping through a hundred hoops. Having a simple "-o internal" option on the command line or in my user profile would save me SO much hassle! Jul 17, 2020 at 22:43
  • @user1944491 You can use this method docs.gitlab.com/ee/api/projects.html#edit-project
    – Tirex
    Jul 18, 2020 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.