多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# Create a project > 原文:[https://docs.gitlab.com/ee/gitlab-basics/create-project.html](https://docs.gitlab.com/ee/gitlab-basics/create-project.html) * [Create a project in GitLab](#create-a-project-in-gitlab) * [Blank projects](#blank-projects) * [Project templates](#project-templates) * [Built-in templates](#built-in-templates) * [Enterprise templates](#enterprise-templates-ultimate) * [Custom project templates](#custom-project-templates-premium) * [Push to create a new project](#push-to-create-a-new-project) # Create a project[](#create-a-project "Permalink") GitLab 中的大多数工作都在一个[Project 中](../user/project/index.html)完成. 文件和代码保存在项目中,并且大多数功能都在项目范围内使用. ## Create a project in GitLab[](#create-a-project-in-gitlab "Permalink") 要在 GitLab 中创建项目: 1. 在信息中心中,点击绿色的**新建项目**按钮或使用导航栏中的加号图标. 这将打开" **新项目"**页面. 2. 在" **新建项目"**页面上,选择是否要: * 创建一个[空白项目](#blank-projects) . * 使用可用的[项目模板](#project-templates)之一创建一个项目. * 如果已在您的 GitLab 实例上启用,则从其他存储库[导入项目](../user/project/import/index.html) . 如果不可用,请与您的 GitLab 管理员联系. * 运行[用于外部存储库的 CI / CD 管道](../ci/ci_cd_for_external_repos/index.html) . **注意:**有关不能用作项目名称的单词列表,请参见[保留的项目和组名称](../user/reserved_names.html) . ### Blank projects[](#blank-projects "Permalink") 要在" **新建项目"**页面上创建一个新的空白项目,请执行以下操作: 1. 在" **空白项目"**选项卡上,提供以下信息: * **项目名称**在**项目名称**字段中. 您不能使用特殊字符,但可以使用空格,连字符,下划线甚至表情符号. 添加名称时, **Project slug**将自动填充. slug 是 GitLab 实例将用作项目的 URL 路径的东西. 如果您要使用其他子弹,请先输入项目名称,然后再更改子弹. * **Project slug**字段中项目的路径. 这是 GitLab 实例将使用的项目的 URL 路径. 如果**项目名称**为空白,则当您填写**项目 slug**时,它将自动填充. * 使用" **项目描述"(可选)**字段,您可以为项目的仪表板输入描述,这将帮助其他人了解您的项目的含义. 尽管不是必需的,但这是个好主意. * 更改" **可见性级别"**会修改用户的项目[查看和访问权限](../public_access/public_access.html) . * 选择**使用 README 初始化存储库**选项将创建一个 README 文件,以便 Git 存储库被初始化,具有默认分支并可以被克隆. 2. Click **建立专案**. ### Project templates[](#project-templates "Permalink") 项目模板可以使用必要的文件预填充新项目,以使您快速入门. 有两种类型的项目模板: * [内置模板](#built-in-templates) ,来自以下组: * [`project-templates`](https://gitlab.com/gitlab-org/project-templates) * [`pages`](https://gitlab.com/pages) * [自定义项目模板](#custom-project-templates-premium) ,用于由 GitLab 管理员和用户配置的自定义模板. #### Built-in templates[](#built-in-templates "Permalink") 内置模板是项目模板,它们是: * 在[`project-templates`](https://gitlab.com/gitlab-org/project-templates)和[`pages`](https://gitlab.com/pages)组中开发和维护. * 与 GitLab 一起发布. 要在" **新建项目"**页面上使用内置模板,请执行以下操作: 1. 在" **从模板创建"**选项卡上,选择" **内置"**选项卡. 2. 从可用的内置模板列表中,单击: * **预览**按钮以查看模板源本身. * **使用模板**按钮开始创建项目. 3. 通过填写项目的详细信息来完成创建项目. 该过程与创建[空白项目](#blank-projects)相同. ##### Enterprise templates[](#enterprise-templates-ultimate "Permalink") GitLab 正在开发企业模板,以帮助您根据选定的法规标准简化审核管理. 这些模板会自动导入与每个法规要求相对应的问题. 要使用企业模板创建新项目,请在" **新建项目"**页面上: 1. 在" **从模板创建"**选项卡上,选择" **内置"**选项卡. 2. 从可用的内置企业模板列表中,单击: * **预览**按钮以查看模板源本身. * **使用模板**按钮开始创建项目. 3. 通过填写项目的详细信息来完成创建项目. 该过程与创建[空白项目](#blank-projects)相同. 可用的企业模板包括: * HIPAA 审核协议模板(在 GitLab 12.10 中[引入](https://gitlab.com/gitlab-org/gitlab/-/issues/13756) ) **提示:**您可以按照[以下步骤](https://gitlab.com/gitlab-org/project-templates/contributing)改进现有的内置模板或在[`project-templates`](https://gitlab.com/gitlab-org/project-templates)和[`pages`](https://gitlab.com/pages)组中添加新的[`project-templates`](https://gitlab.com/gitlab-org/project-templates) . #### Custom project templates[](#custom-project-templates-premium "Permalink") [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/6860) in [GitLab Premium](https://about.gitlab.com/pricing/) 11.2. Creating new projects based on custom project templates is a convenient option for quickly starting projects. 自定义项目可以在[实例级别](../user/admin_area/custom_project_templates.html)从**实例**选项卡,或在[组级别](../user/group/custom_project_templates.html)从**组**选项卡,在**从模板**标签上的**创建** . 要在" **新建项目"**页面上使用自定义项目模板: 1. 在" **从模板创建"**选项卡上,选择" **实例"**选项卡或" **组"**选项卡. 2. 从可用的自定义模板列表中,单击: * **预览**按钮以查看模板源本身. * **使用模板**按钮开始创建项目. 3. 通过填写项目的详细信息来完成创建项目. 该过程与创建[空白项目](#blank-projects)相同. ## Push to create a new project[](#push-to-create-a-new-project "Permalink") 在 GitLab 10.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/26388) . 当您在本地创建新的存储库时,无需直接在 GitLab 上手动创建一个新项目然后[在](start-using-git.html#clone-a-repository)本地[克隆该](start-using-git.html#clone-a-repository)存储库,而无需将其直接发送到 GitLab 即可创建新项目. 如果您具有关联的名称空间的访问权,则 GitLab 将在该 GitLab 名称空间下自动创建一个新项目,其可见性默认设置为 Private(您以后可以在[项目的设置中](../public_access/public_access.html#how-to-change-project-visibility)对其进行更改). 这可以通过使用 SSH 或 HTTPS 来完成: ``` ## Git push using SSH git push --set-upstream git@gitlab.example.com:namespace/nonexistent-project.git master ## Git push using HTTPS git push --set-upstream https://gitlab.example.com/namespace/nonexistent-project.git master ``` 推送成功完成后,将显示一条远程消息,指示将遥控器和 URL 设置为新项目的命令: ``` remote: remote: The private project namespace/nonexistent-project was created. remote: remote: To configure the remote, run: remote: git remote add origin https://gitlab.example.com/namespace/nonexistent-project.git remote: remote: To view the project, visit: remote: https://gitlab.example.com/namespace/nonexistent-project remote: ```