此版本的 GitHub Enterprise 已停止服务 2021-09-23. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

创建仓库

要将项目放在 您的 GitHub Enterprise Server 实例 上,您需要创建一个仓库来存放它。

创建仓库

您可以在 GitHub Enterprise Server 仓库中存储各种项目,包括内部来源项目。 通过内部源代码,您可以分享代码来获取更好、更可靠的软件。 有关内部资源的更多信息,请参阅 GitHub 的白皮书“内部资源简介”。

  1. 在任何页面的右上角,使用 下拉菜单选择 New repository(新建仓库)带有创建新仓库选项的下拉菜单
  2. 为仓库键入简短、令人难忘的名称。 例如 "hello-world"。 用于输入仓库名称的字段
  3. (可选)添加仓库的说明。 例如,“我在 GitHub Enterprise Server 上的第一个仓库”。 用于输入仓库说明的字段
  4. 选择仓库可见性。 更多信息请参阅“关于仓库”。 选择仓库可见性的单选按钮
  5. 选择 Initialize this repository with a README(使用自述文件初始化此仓库)使用自述文件初始化此仓库复选框
  6. 单击 Create repository(创建仓库)Button to create repository

恭喜! 您已成功创建第一个仓库,并使用自述文件对其进行了初始化。

To learn more about GitHub CLI, see "About GitHub CLI."

  1. In the command line, navigate to the directory where you would like to create a local clone of your new project.

  2. To create a repository for your project, use the gh repo create subcommand. Replace project-name with the desired name for your repository. If you want your project to belong to an organization instead of to your user account, specify the organization name and project name with organization-name/project-name.

    gh repo create project-name
  3. Follow the interactive prompts. To clone the repository locally, confirm yes when asked if you would like to clone the remote project directory. Alternatively, you can specify arguments to skip these prompts. For more information about possible arguments, see the GitHub CLI manual.

提交您的第一个更改

A 提交就像是项目中所有文件在特定时间点的快照。

创建新仓库时,您使用自述文件对其进行了初始化。 自述文件是详细介绍项目的好工具,您也可以添加一些文档,例如介绍如何安装或使用项目的文档。 自述文件的内容自动显示在仓库的首页上。

让我们提交对自述文件的更改。

  1. 在仓库的文件列表中,单击 README.md文件列表中的自述文件
  2. 在文件内容的上方,单击
  3. Edit file(编辑文件)选项卡上,键入一些关于您自己的信息。 文件中的新内容
  4. 在新内容上方,单击 Preview changes(预览更改)文件预览按钮
  5. 查看您对文件所做的更改。 您会看到新内容以绿色显示。 文件预览视图
  6. 在页面底部,输入一条简短、有意义的提交消息,描述您对文件所作的更改。 您可以在提交消息中将提交归于多个作者。 更多信息请参阅“创建有多个合作作者的提交”。 有关更改的提交消息
  7. 在提交消息字段下面,确定是要将提交添加到当前分支还是新分支。 如果当前分支是默认分支,则应选择为提交创建新分支,然后创建拉取请求。 更多信息请参阅“创建新的拉取请求”。 提交分支选项
  8. 单击 Propose file change(提议文件更改)提议文件更改按钮

Now that you have created a project, you can start committing changes.

自述文件是详细介绍项目的好工具,您也可以添加一些文档,例如介绍如何安装或使用项目的文档。 自述文件的内容自动显示在仓库的首页上。 Follow these steps to add a README file.

  1. In the command line, navigate to the root directory of your new project. (This directory was created when you ran the gh repo create command.)

  2. Create a README file with some information about the project.

    echo "info about this project" >> README.md
  3. Enter git status. You will see that you have an untracked README.md file.

    $ git status
    
    Untracked files:
      (use "git add ..." to include in what will be committed)
      README.md
    
    nothing added to commit but untracked files present (use "git add" to track)
  4. Stage and commit the file.

    git add README.md && git commit -m "Add README"
  5. Push the changes to your branch.

    git push --set-upstream origin HEAD

祝贺

恭喜! 您现在已经创建了一个仓库,其中包括自述文件,并在 您的 GitHub Enterprise Server 实例 上创建了您的第一个提交。

您现在可以克隆 GitHub Enterprise Server 仓库以在计算机上创建本地副本。 从您的本地仓库,您可以提交并创建拉取请求来更新上游仓库中的更改。 更多信息请参阅“克隆仓库”和“设置 Git”。

您可以在 GitHub Enterprise Server 上找到有趣的项目和仓库,并通过创建仓库的复刻来更改它们。 更多信息请参阅“复刻仓库”。

GitHub Enterprise Server 中的每个仓库均归个人或组织所有。 您可以在 GitHub Enterprise Server 上连接和关注人员、仓库和组织以与之进行交互。 更多信息请参阅“社交”。

GitHub Enterprise Server 有一个强大的支持社区,您可以在那里寻求帮助并与来自世界各地的人交谈。 加入 Github 支持社区的对话。