github上拉取项目_如何在GitHub上发出第一个拉取请求

github上拉取项目

Many tutorials exist about this topic but they make things overly complicated by assuming one has to contribute code to a project.

有许多关于该主题的教程,但是它们通过假定必须向项目贡献代码而使事情变得过于复杂。

What if they just need to edit a file, maybe the project README to fix a typo?

如果他们只需要编辑文件,也许是项目README来解决错字怎么办?

You don't need to know how to code or how to use Git to do that. But once you start doing Pull Requests, you can do many more things and collaborate on projects with other people! And maybe this will push you to also contribute code later on.

您不需要知道如何编码或如何使用Git来做到这一点。 但是,一旦开始执行“拉取请求”,您就可以做更多的事情,并与其他人协作进行项目! 也许这将促使您以后也贡献代码。

I assume you already have a (free) GitHub account. If you don't, then go to github.com and get one.

我假设您已经有一个(免费的)GitHub帐户。 如果不这样做,请访问github.com并获取一个。

Let me show you the process.

让我告诉你这个过程。

I went to this page https://web.dev/prefers-color-scheme/ and I found a possible typo. This line is missing a dot at the end.

我转到此页面https://web.dev/prefers-color-scheme/ ,发现了可能的错字。 这条线的末尾缺少一个点。

article-i-want-to-edit

I'm not a stickler for grammar, this is just for the sake of finding an example ?

我不是语法狂热者,这仅仅是为了寻找一个例子?

I know that site is hosted on GitHub, and that exact article is hosted here: https://github.com/GoogleChrome/web.dev/tree/master/src/site/content/en/blog/prefers-color-scheme

我知道该网站托管在GitHub上,并且确切的文章托管在这里: https : //github.com/GoogleChrome/web.dev/tree/master/src/site/content/en/blog/prefers-color-scheme

github-folder-for-article

I open the index.md file https://github.com/GoogleChrome/web.dev/blob/master/src/site/content/en/blog/prefers-color-scheme/index.md directly on GitHub and I press the pencil icon in the file toolbar. Hovering it says "Fork this project and edit the file".

我直接在GitHub上打开index.md文件https://github.com/GoogleChrome/web.dev/blob/master/src/site/content/en/blog/prefers-color-scheme/index.md ,然后按文件工具栏中的铅笔图标。 将鼠标悬停在它上面,显示“分叉此项目并编辑文件”。

the-index-md-file

This brings up an editor view with this information:

这将显示以下信息的编辑器视图:

You’re editing a file in a project you don’t have write access to. Submitting a change to this file will write it to a new branch in your fork flaviocopes/web.dev, so you can send a pull request.

您正在编辑一个没有写权限的项目中的文件。 提交对此文件的更改会将其写入到分支flaviocopes / web.dev中的新分支中,因此您可以发送拉取请求。

the-editor-view

I can go and add that dot, then at the form at the bottom I explain the changes I made:

我可以添加该点,然后在底部的表单中说明所做的更改:

propose-file-change

I pressed the "Propose File Change" button and a compare view showed up.

我按下“建议更改文件”按钮,然后显示一个比较视图。

compare-view

There I can review the changes I made, to make sure all is fine, and finally I can click the "Create Pull Request" button. Currently the changes have been made to your fork of the project, which was made automatically by GitHub when you clicked the pencil icon.

在这里,我可以查看所做的更改,以确保一切都很好,最后,我可以单击“创建请求请求”按钮。 当前,已对项目的分支进行了更改,这是由GitHub在单击铅笔图标时自动进行的。

open-pull-request

At the top of this view you can see that I'm about to submit a PR to the GoogleChrome/web.dev project from my form flaviocopes/web.dev, from my branch patch-2 to their master branch.

在此视图的顶部,您可以看到我即将从flaviocopes/web.dev (从我的分支patch-2到其master分支)向GoogleChrome/web.dev项目提交PR。

Pressing the "Create Pull Request" button shows another form where I can write a detailed description for the Pull Request.

按下“创建请求请求”按钮将显示另一种形式,我可以在其中编写请求请求的详细说明。

Pull Requests can contain many different changes, so in theory you could have lots of files edited in the same PR, this is why you can add a summary.

拉取请求可能包含许多不同的更改,因此从理论上讲,您可以在同一PR中编辑许多文件,这就是为什么您可以添加摘要的原因。

This repository has a template for the PR text, to help the team manage it. Our PR is very simple so I remove the template and just paste the content from the commit message from before.

该存储库具有用于PR文本的模板,以帮助团队进行管理。 我们的PR非常简单,因此我删除了模板,仅粘贴了之前提交消息中的内容。

Notice the hint on the right? They tell me the project has a CONTRIBUTING.md file, which explains how to contribute and the guidelines. Pretty cool.

注意右边的提示吗? 他们告诉我该项目有一个CONTRIBUTING.md文件,该文件说明了如何进行贡献和指导原则。 很酷

contributing

Seems we need to sign a CLA (Contributor License Agreement) to complete our PR. I already signed a Google CLA in the past so this step is clear for me, but you might need to fix that. Most projects don't really need it.

似乎我们需要签署CLA(贡献者许可协议)才能完成PR。 我过去已经签署了Google CLA,因此这一步骤对我来说很清楚,但是您可能需要解决此问题。 大多数项目并不真正需要它。

I clicked "Create pull request" and the PR is now sent!

我单击“创建请求请求”,然后发送PR!

pull-request-sent

Now it's up to the project maintainers to step in and accept it, you just need to wait for an email telling you that it's been merged, or any comments other people had.

现在由项目维护者介入并接受它,您只需要等待一封电子邮件,告诉您它已被合并,或者其他人有任何评论。

[... a couple hours passed by...]

[...几个小时过去了...]

I got an email back, the PR was rejected because that dot was actually in the correct place! (I didn't know that).

我收到了一封电子邮件,公关被拒绝了,因为那个点实际上在正确的位置! (我不知道)。

But anyway here's a thing I wanted to add: don't be angry or upset if a PR you submit is not accepted. The maintainers of the project work on it for months or years and they know better than you about what's better for it.

但是无论如何,这是我想补充的一点:如果您提交的PR不被接受,请不要生气或沮丧。 项目的维护者需要花费数月或数年的时间,他们比您更了解什么对它更好。

Plus, especially with code, views might be very very different and a PR you think is great might not be welcome.

另外,尤其是对于代码,视图可能会非常不同,并且可能不欢迎您认为很棒的PR。

It's also best to ask before working on a substantial PR, to see if it's something the project actually needs.

也最好在进行实质性PR之前先询问一下,看看它是否是项目真正需要的东西。

Bug fixes are easy starts.

修复错误很容易。



I'm Flavio. I write tutorials for developers at flaviocopes.com

我是弗拉维奥 我在flaviocopes.com上为开发人员编写了教程

翻译自: https://www.freecodecamp.org/news/how-to-make-your-first-pull-request-on-github/

github上拉取项目