Skip to content

在线存储你的存储库

Get ready to…

  • 将你的项目存储库放到网上

本教程将使用 GitHub 来存储我们的存储库并连接到 Web 主机。欢迎你使用你选择的在线 git 提供商。

¥This tutorial will use GitHub to store our repository and connect to a web host. You are welcome to use the online git provider of your choice.

¥Create a repository on GitHub

尽管有几种方法可以将本地代码存储在 GitHub 中,但本教程将指导你完成一种不需要在命令行中使用 git 的方法。

¥Although there are a few ways to get your local code stored in GitHub, this tutorial will guide you through a method that does not require using git in the command line.

  1. Log in to GitHub.com in a browser and click the + in the upper right of the screen to make a new repository.

  2. Choose a name for your repository. This does not have to be the same name as your project folder.

  3. You will be presented with options, but you do not need to change any of the defaults. Scroll down and click the button to Create Repository.

  4. You will be presented with various setup next steps, but you won’t need to use any of them. Make a note of the URL of your repository. You can now exit this page without doing anything.

将本地代码提交到 GitHub

Section titled 将本地代码提交到 GitHub

¥Commit your local code to GitHub

在上一部分中,你对页面内容进行了更改。这意味着你的项目文件已更改,VS Code 应在 “来源” 菜单图标顶部显示一个数字。你将定期在该源选项卡中更新 GitHub 上的文件。

¥In the last section, you made a change to your page’s content. This means that your project files have changed, and VS Code should show a number on top of the “Source” menu icon. This source tab is where you will regularly go to update your files on GitHub.

  1. Click the Source Control tab in your VS Code to see a list of files that have changed. If you see a message that you need to install git, follow the instructions provided, then reload VS Code.

  2. Click the ••• “3 dots” menu above the commit message and choose Remote > Add Remote.

  3. Select Add remote from GitHub. If necessary, follow any authentication steps then return to VS Code and repeat this action.

  4. You should see a list of all your repositories on GitHub. Choose the one you created for this project. If you don’t see your project, paste in its GitHub URL directly. You may also be asked to give this repository a local name. You can select any name you like.

  5. At the top of the menu pane, there will be a place to enter a commit message (description of your file changes). Type in initial commit and press the Commit button to commit these changes.

  6. You may see a message telling you that you have no “staged” commits, and asking you if you want to stage them. Click Always and continue.

  7. Lastly, the list of changed files should be replaced with a Publish button. Click this to send your committed changes to GitHub.

在 GitHub 上查看你的项目

Section titled 在 GitHub 上查看你的项目

¥See your project on GitHub

要验证你的项目是否已成功存储在 GitHub 上,请访问 GitHub.com 并在你的账户下查看你的存储库列表。选择你创建的新文件,并验证它是否包含你的 Astro 项目文件。

¥To verify that your project is successfully stored on GitHub, visit GitHub.com and look under your account for a list of your repositories. Choose the new one you created, and verify that it contains your Astro project files.

¥Checklist

¥Resources

Astro 中文网 - 粤ICP备13048890号