

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 步骤 2：创建 GitHub 存储库
<a name="tutorials-github-create-github-repository"></a>

您将需要一个 GitHub 存储库来存储修订版。

如果您已经有 GitHub 存储库，请务必在本教程**CodeDeployGitHubDemo**中使用其名称代替，然后直接跳到[步骤 3：将示例应用程序上传到您的 GitHub 存储库](tutorials-github-upload-sample-revision.md)。

1. 在[GitHub 主页](https://github.com/dashboard)上，执行以下任一操作：
   + 在 **Your repositories** 中，选择 **New repository**。
   + 在导航栏上，选择 **Create new**（**\$1**），然后选择 **New repository**。

1. 在 **Create a new repository** 页上，执行下列操作：
   + 在**存储库名称**框中，输入 **CodeDeployGitHubDemo**。
   + 选择 **Public**。
**注意**  
选择默认的 **Public（公有）**选项意味着任何人均可查看此存储库。您可以选择 **Private（私有）**选项，限制可对存储库执行查看和提交的人员。
   + 清除 **Initialize this repository with a README（使用自述文件初始化此存储库）**复选框。您将改为在下一步中手动创建 `README.md` 文件。
   + 选择**创建存储库**。

1. 按照适用于您的本地计算机类型的说明操作以使用命令行创建存储库。
**注意**  
如果您启用了双重身份验证 GitHub，请确保在提示输入密码时输入个人访问令牌而不是 GitHub 登录密码。有关信息，请参阅[提供您的双重身份验证代码](https://help.github.com/articles/providing-your-2fa-authentication-code/)。

**在本地 Linux、macOS 或 Unix 计算机上：**

1. 在终端上，逐一运行以下命令，您的 GitHub 用户名在*user-name*哪里：

   ```
   mkdir /tmp/CodeDeployGitHubDemo
   ```

   ```
   cd /tmp/CodeDeployGitHubDemo
   ```

   ```
   touch README.md
   ```

   ```
   git init
   ```

   ```
   git add README.md
   ```

   ```
   git commit -m "My first commit"
   ```

   ```
   git remote add origin https://github.com/user-name/CodeDeployGitHubDemo.git
   ```

   ```
   git push -u origin master
   ```

1. 在 `/tmp/CodeDeployGitHubDemo` 位置保持终端打开。

**在本地 Windows 计算机上：**

1. 以管理员身份从命令提示符运行以下命令（一次运行一条命令）：

   ```
   mkdir c:\temp\CodeDeployGitHubDemo
   ```

   ```
   cd c:\temp\CodeDeployGitHubDemo
   ```

   ```
   notepad README.md
   ```

1. 在记事本中，保存 `README.md` 文件。关闭记事本。逐一运行以下命令，您的 GitHub 用户名在*user-name*哪里：

   ```
   git init
   ```

   ```
   git add README.md
   ```

   ```
   git commit -m "My first commit"
   ```

   ```
   git remote add origin https://github.com/user-name/CodeDeployGitHubDemo.git
   ```

   ```
   git push -u origin master
   ```

1. 在 `c:\temp\CodeDeployGitHubDemo` 位置保持终端打开。