github请求超时
“Can you create a PR?”
“您可以创建公关吗?”
Have you ever heard that and had to Google around for PR’s and how to get one done successfully? Well, you’ve come to the right place. We are going to start from the beginning of creating your first Pull Request.
您是否听说过,不得不到Google寻求公关,以及如何成功完成公关 ? 好吧,您来对地方了。 我们将从创建第一个拉取请求开始。
什么是拉取请求(PR)? ( What Exactly is a Pull Request (PR)? )
A Pull Request, or PR, is a way to contribute to a repository in GitHub.
拉取请求(PR)是向GitHub中的存储库做出贡献的一种方式。
A Pull Request allows us to contribute code to our own repo, our teams repo, or an open source repo.
拉取请求允许我们向自己的仓库,团队仓库或开源仓库提供代码。
The repository needs to be open, or you need to have permission to be able to submit a PR. If you have permission, then go ahead and follow the upcoming steps! If you do not, simply "Fork and Clone" the repository. Once you Fork it, then it will live on your own GitHub account as a forked repo.
存储库需要打开,或者您需要具有权限才能提交PR。 如果您有权限,请继续并按照接下来的步骤进行操作! 如果不这样做,则只需“分叉并克隆”存储库即可。 分叉后,它将作为分叉的存储库存在于您自己的GitHub帐户上。
为什么提出拉取请求? (Why Make a Pull Request?)
Pull Requests are a big deal in the world of collaborative coding. If you've ever heard the term open source, then you may be familiar with this concept of having anyone see your code and make suggestions to it.
在协作编码领域,拉取请求非常重要。 如果您曾经听说过开源一词,那么您可能熟悉让任何人看到您的代码并提出建议的概念。
You could even contribute to some of the code changes and even issues on favorite projects like React. We can see the pull requests that others have done to help make React a better library.
您甚至可以为某些代码更改做出贡献,甚至还可以为喜欢的项目(如React)上的问题做出贡献。 我们可以看到其他人所做的拉取请求,以帮助使React成为一个更好的库。
An example of why you would want to make a Pull Request is you are working on a team and you contribute to the repository. Creating a PR is important because we wouldn't want to push to the master branch until code reviews are completed and a teammate approves it.
为什么要提出“拉取请求”的一个示例是,您正在团队中工作,并且为存储库做出了贡献。 创建PR很重要,因为在代码审查完成并且队友批准之前,我们不希望推送到master分支。
Let's talk about the steps to create a pull request on a project. We'll be walking through the steps to grab a project and make a pull request.
让我们讨论在项目上创建拉取请求的步骤。 我们将逐步完成抓取项目并提出请求的步骤。
克隆到项目 ( Cloning into a Project )
There are two ways to start the process.
有两种方法可以启动该过程。
- Cloning another’s project 克隆他人的项目
- Your own project you started from scratch (not very likely) 从头开始的自己的项目(不太可能)
The most common case is going to be #1. So we are going to start this example by cloning into a project that was created earlier. It’s a basic React app that was created via the command create-react-app
. We can find that GitHub repo here.
最常见的情况将是#1。 因此,我们将通过克隆到之前创建的项目来开始本示例。 这是通过命令create-react-app
的基本React create-react-app
。 我们可以在这里找到GitHub存储库 。
Once in that GitHub repo, click on the green button that says, "Clone or download". A dropdown will show us a password protected SSH key. You can change it to HTTP by clicking "Use HTTPS" in the upper right-hand corner of that dropdown. We are going to use the SSH way in this article.
进入该GitHub存储库后,单击绿色按钮“克隆或下载”。 下拉列表将为我们显示受密码保护的SSH密钥。 您可以通过单击该下拉菜单右上角的“使用HTTPS”将其更改为HTTP。 我们将在本文中使用SSH方式。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402258/a2lkqalt29xxmjxvna30.png)
Copy that key! We are going to need it soon!
复制该密钥! 我们将很快需要它!
In your terminal (we are on iOS for this example), navigate to the location in your computer where you would like this project to live. To learn more about navigating throughout the Terminal, check out this article on "10 Need to Know Mac Terminal Commands"!
在您的终端(本例中为iOS)上,导航到计算机中您希望此项目存在的位置。 要了解有关在整个终端中导航的更多信息,请查看“ 10个需要知道Mac终端命令”的文章 !
Using the following command, we are going to officially clone the project and be able to have all the code on our local machine:
使用以下命令,我们将正式克隆项目,并能够将所有代码存储在本地计算机上:
git clone [git@github.com](mailto:git@github.com):kapehe-ok/react-git-pr.git
Use the command to get into the project:
使用命令进入项目:
cd react-git-pr
Now we are cloned into the project and can start with our first PR!
现在我们被克隆到项目中,可以从我们的第一个PR开始!
For the remainder of the article, let's work in VS Code. Go ahead and open up the code in VS Code.
在本文的其余部分,让我们在VS Code中工作。 继续并在VS Code中打开代码。
- Note! From the Terminal, a short cut to open VS Code is
code .
This needs to be installed. Within VS Code hit "cmd + shift + P". Type in "Shell command: Install 'code' command in PATH." and hit "Enter". From now on, you can usecode .
to open up VS Code from Terminal. 注意! 在终端上,打开VS Code的快捷方式是code .
这需要安装。 在VS Code中,点击“ cmd + shift + P”。 键入“ Shell命令:在PATH中安装'code'命令。” 然后点击“ Enter”。 从现在开始,您可以使用code .
从终端打开VS Code。
制作分支 ( Making a Branch )
When making a PR, we want to create our own branch. If someone is having you create a PR it's because they don't want you to push to the Master branch. Using the following command, we jump out of the Master branch and into our own branch:
进行PR时,我们要创建自己的分支。 如果有人要创建PR,那是因为他们不希望您推送到Master分支。 使用以下命令,我们跳出Master分支并进入自己的分支:
git checkout -b kapehe-first-pr
The 'b
in this is indicating that we are creating a brand new branch. The kapehe-first-pr
is the name of the branch. Feel free to name a branch whatever is fitting.
'b
表示我们正在创建一个全新的分支。 kapehe-first-pr
是分支的名称。 随意命名一个合适的分支。
- Want to double-check you are in the new branch? At the bottom left-hand corner of VS Code, you'll see the name of the branch you are on. If we see "kapehe-first-pr" there, then we did it right! If we see "master", something's not right! 是否想再次检查您是否在新分支中? 在VS Code的左下角,您将看到所在分支的名称。 如果我们在那里看到“ kapehe-first-pr”,那么我们做对了! 如果看到“主人”,那是不对的!
创造变化 ( Creating a Change )
Make any change within the code just so we have a change to commit in the PR. We can dive into src/App.js
and edit the <div>
in there. We can edit it to have the line <h1>Aloha! Kapehe here!!</h1>
! Let's hit "Save" and get ready to make this PR!
在代码中进行任何更改,只是为了更改PR中的内容。 我们可以进入src/App.js
并在其中编辑<div>
。 我们可以对其进行编辑以使其具有<h1>Aloha! Kapehe here!!</h1>
<h1>Aloha! Kapehe here!!</h1>
! 让我们点击“保存”,准备好进行此PR!
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402289/v1zbqjczxzx95m6ilfcw.png)
发出拉取请求 ( Making the Pull Request )
There are a string of commands that we are going to be doing here to make our first official PR. We'll go over each one!
我们将在此处执行一系列命令以进行我们的第一个正式PR。 我们将逐一讨论!
git状态 (git status)
We want to check the status of all the files we changed. To do that, run the command:
我们要检查所有更改文件的状态。 为此,请运行以下命令:
git status
All the files that we changed and saved will show up here in red. Check out this screenshot to see how that would look:
我们更改和保存的所有文件都将以红色显示在此处。 查看此屏幕截图以查看效果:
Because we change the src/App.js
file, we see that in red here.
因为我们更改了src/App.js
文件,所以在这里看到红色。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402316/yhycjkt1nax8loim5vjv.png)
git添加 (git add)
There are many ways to add the files to the queue to get pushed into the PR. In this article, we'll go over two different ways.
有很多方法可以将文件添加到队列中以推送到PR中。 在本文中,我们将介绍两种不同的方法。
git add .
- This will add every single file that shows up red when runninggit status
git add .
-这将添加运行git status
时显示为红色的每个文件git add <filename>
- This command allows us to type in the particular file we would like to add.git add <filename>
-此命令允许我们键入要添加的特定文件。
In today's example, we are going to use the second way. Go ahead and run the command:
在今天的示例中,我们将使用第二种方法。 继续运行命令:
git add src/App.js
And we should nothing happen! So how do we know it was added? Or at least the right files were added? Run our git status
command again!
而且我们什么也不会发生! 那么我们怎么知道它被添加了呢? 还是至少添加了正确的文件? 再次运行我们的git status
命令!
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402341/xwurztul1lpzkxcisnxd.png)
We now see that src/App.js
is now in green! That means it was added and we are good to commit this change.
现在,我们看到src/App.js
了绿色! 这意味着已经添加了它,我们很高兴提交此更改。
git提交 (git commit)
This command is where we name our commit. We generally want the commit message to coincide with what is happening in the file updates. Now that our file is added to the queue, let's go ahead and commit it. Run the following command:
这个命令就是我们命名提交的地方。 我们通常希望提交消息与文件更新中发生的事情一致。 现在我们的文件已添加到队列中,让我们继续进行提交。 运行以下命令:
git commit -m "Updating App.js div text"
The -m
in this command is stating that we want to create our message within this command. The "Updating App.js div text"
is our commit message. We can put whatever we want here. Try and make it make sense for what changes occurred.
此命令中的-m
表示我们要在此命令中创建消息。 "Updating App.js div text"
是我们的提交消息。 我们可以在这里放任何东西。 尝试使发生的更改有意义。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402362/zuu3pibbectfn3afbzzh.png)
git推 ( git push )
Here we are! We made it to the final PUSH!
我们来了! 我们进入了最后的推!
To push all of our updated work to the GitHub repo in the form of a Pull Request, run the following command:
要将我们所有更新的工作以“拉取请求”的形式推送到GitHub存储库,请运行以下命令:
git push origin kapehe-first-pr
That last part of the command is our branch name! Make sure that matches up exactly with the branch name so that there are no issues when pushing.
该命令的最后一部分是我们的分支名称! 确保与分支名称完全匹配,以便在推送时没有问题。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402380/begcwclns0znhnmzduui.png)
We pushed! But we are not done!
我们推! 但是我们还没有完成!
创建请求请求! ( Creating the Pull Request! )
In this final step, we need to head back to the GitHub repo.
在这最后一步,我们需要回到GitHub存储库。
Right away, we should see the following:
立即,我们应该看到以下内容:
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402398/v8pzsooq4q6jywum1bsm.png)
That light yellow line is new! That's showing our branch and that a push was created "(less than a minute ago)". See that green button that says "Compare & pull request". Let's hit that!
那条淡黄色的线是新的! 那显示了我们的分支,并且创建了“(不到一分钟前)”的推送。 看到显示“比较并提取请求”的绿色按钮。 让我们开始吧!
Once we do that, we can rename the Pull Request here, but for now, we'll just keep it as what we named it when we were committing it, "Updating App.js div text". Hit the green button that says "Create pull request".
完成此操作后,我们可以在此处重命名“拉取请求”,但现在,我们将其保留为提交时命名的名称,即“更新App.js div文本”。 点击绿色按钮,显示“创建请求请求”。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402414/hwhaksqxacbzywsr9unk.png)
It's done! We have created our first Pull Request!
完成! 我们已经创建了第一个请求请求!
确认拉取请求 ( Confirming the Pull Request )
To double-check that everything is good, we can click on the tab that says "Pull requests". There we will see our PR and any other PR's.
要再次检查一切都很好,我们可以单击“拉出请求”标签。 在那里,我们将看到我们的PR和其他任何PR。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402429/zxstmzglbe1zossscldi.png)
Once we click into that, we will see details about our PR. We can see what was changed by clicking on the "Files Changed" tab, we can look at all the commits that happened under the "Commits" tab, and we can even merge into the master branch on the "Conversation" tab.
单击此按钮后,我们将看到有关PR的详细信息。 我们可以单击“文件已更改”选项卡来查看更改的内容,可以查看“提交”选项卡下发生的所有提交,甚至可以合并到“会话”选项卡上的master分支中。
To merge into master, we would click on that green button that says "Merge pull request". Only do this when the PR is approved. Most likely, the owner of the project will coordinate on who merges the PR into master. It's probably a safe bet to not do it.
要合并到主服务器,我们将单击显示“合并请求”的绿色按钮。 仅在批准PR时执行此操作。 最有可能的是,项目的所有者将协调谁将PR合并为Master。 不这样做可能是一个安全的选择。
![](https://scotch-res.cloudinary.com/image/upload/w_auto,q_auto:good,f_auto/v1587402449/lpr2tduav3lp7yoqpkqj.png)
回顾 ( Recap )
Let's recap those steps quickly:
让我们快速回顾一下这些步骤:
- Cloning into a project 克隆到项目
- Creating a new branch off of the master branch 从master分支创建一个新分支
git status
git status
git add .
orgit add <filename>
git add .
或git add <filename>
git status
git status
git commit -m "message here"
git commit -m "message here"
git push origin <branchname>
git push origin <branchname>
- Go to the repo in GitHub and create the pull request! 转到GitHub中的仓库并创建拉取请求!
- Tada!! 🎉PR Created! 多田!! 🎉PR已创建!
结语! ( Wrap Up! )
Now that we have created our first Pull Request, go practice some more. Take a project of your own, create branches off of it, and practice creating PR's! The more you practice, the better we'll get at it!
现在,我们已经创建了第一个“拉取请求”,请继续练习。 做一个自己的项目,从中创建分支,然后练习创建PR! 您练习得越多,我们就会越好!
翻译自: https://scotch.io/tutorials/creating-your-first-pull-request-in-github
github请求超时