[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) [![Open Source Helpers](https://www.codetriage.com/roshanjossey/first-contributions/badges/users.svg)](https://www.codetriage.com/roshanjossey/first-contributions) # 第一次参与开源项目 万事开头难。特别是和其他人合作时,出错往往会令人不适。不过,开源的本质就是和他人合作。这个项目的初衷就是为初学者提供一个简单的方法去学习以及参与开源项目。 你可以通过阅读文章和观看教程来得到帮助,但上手实操才是最好的学习方式。本项目旨在简化并指导初学者参与他们的第一次开源。记住:过程越轻松,学习效益越高。如果你想要做出第一次贡献,只需按照以下简单步骤操作即可。这将会是一个很有趣的过程 :) _如果你对 command line(命令行)不熟悉,请参考以下的 [GUI 工具教程](#使用其他工具的教程)。_ fork this repository #### 如果你的电脑上未安装 git, 请参考 [GitHub 文档](https://docs.github.com/cn/get-started/quickstart/set-up-git) 进行安装。 ## Fork(复制)本代码仓库 点击图示中的按钮去 Fork 这个代码仓库。 这个操作会将代码仓库复制到你的账户名下。 ## Clone(克隆)代码仓库 clone this repository 接下来将复制的代码仓库克隆到你的电脑上。点击图示中的绿色按钮,接着点击复制到剪切板按钮(将代码仓库地址复制下来) 随后打开命令行窗口,敲入如下 git 命令: ``` git clone "刚才复制的 url 链接" ``` "刚才复制的 url 链接"(去掉双引号)就是复制到你账户名下的代码仓库地址。获取该链接的方法详见上一步。 copy URL to clipboard 譬如: ```bash git clone git@github.com:/first-contributions.git ``` 'Github 用户名' 指的是你的 Github 用户名。这一步,这个操作将会克隆你账户名下 first-contributions 这个代码仓库到本地电脑上。 ## 新建一个代码分支 在命令行窗口中把目录切换到 first-contributions ```bash cd first-contributions ``` 接下来使用 `git switch` 命令新建一个代码分支 ```bash git switch -c <新分支的名称> ``` 譬如: ```bash git switch -c add-myname ``` (新分支的名称不一定需要有 *add*。然而,在新分支的名称加入 *add* 是一件合理的事情,因为这个分支的目的是将你的名字添加到列表中。) ## 对代码进行修改,然后 Commit (提交) 修改 打开 `Contributors.md` 这个文件,更新文件内容,将你的名字加上去,保存修改。`git status` 这命令会列出被改动的文件。接着 `git add` 这命令则可以添加你的改动,就像如下这条命令。 git status ```bash git add Contributors.md ``` 现在就可以使用 `git commit` 命令 commit 你的修改了。 ```bash git commit -m "Add <你的名字> to Contributors list" ``` 将 `<你的名字>` 替换成你的名字 ## 将改动 Push(推送)到 GitHub 使用 `git push` 命令推送代码 ```bash git push origin <分支的名称> ``` 将 `<分支的名称>` 替换为之前新建的分支名称。
如果在 push(发布)过程中出 error(错误),点击这里 - ### Authentication Error
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
  remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
  fatal: Authentication failed for 'https://github.com//first-contributions.git/'
去 [GitHub's tutorial](https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account) 学习如何生成新的 SSH 密匙以及配置。
## 提出 Pull Request 将你的修改供他人审阅 前往你的 Github 代码仓库,你会看到一个 `Compare & pull request` 的按钮。点击该按钮。 create a pull request 接着再点击 `Create pull request` 按钮,正式提交 pull request。 submit pull request 不久之后,我便会把你所有的变化合并到这个项目的主分支。更改合并后,你会收到一封电子邮件通知。 ### [ 更多资料 ](../additional-material/git_workflow_scenarios/additional-material.md) ## 接下来该做什么呢? 祝贺!你刚刚完成了作为贡献者经常会使用到的标准流程:_fork -> clone -> edit -> pull request_ ! 为你的第一次贡献庆祝吧,不要忘记和你的朋友以及你的小迷弟小迷妹们分享我们的[网站](https://roshanjossey.github.io/first-contributions/#social-share)哟! 如果您想更多练习,请查看 [code contributions](https://github.com/roshanjossey/code-contributions)。 接下来,让我们带你开始参与到其他项目中来。我们整理了一份包含一些简单入门问题的项目清单,方便你快速上手。请查看这个[项目清单](https://firstcontributions.github.io/#project-list)。 ### [附加材料](additional-material/git_workflow_scenarios/additional-material.md) ## 使用其他工具的教程 | GitHub Desktop | Visual Studio 2017 | GitKraken | VS Code | Sourcetree App | IntelliJ IDEA | | --- | --- | --- | --- | --- | --- | | [GitHub Desktop](../gui-tool-tutorials/github-desktop-tutorial.md) | [Visual Studio 2017](../gui-tool-tutorials/github-windows-vs2017-tutorial.md) | [GitKraken](../gui-tool-tutorials/gitkraken-tutorial.md) | [Visual Studio Code](../gui-tool-tutorials/github-windows-vs-code-tutorial.md) | [Atlassian Sourcetree](../gui-tool-tutorials/sourcetree-macos-tutorial.md) | [IntelliJ IDEA](../gui-tool-tutorials/github-windows-intellij-tutorial.md) |

项目支持者: