博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
github上拉取项目_如何在GitHub上发出第一个拉取请求
阅读量:2523 次
发布时间:2019-05-11

本文共 8932 字,大约阅读时间需要 29 分钟。

github上拉取项目

什么是分叉? (What is forking?)

When we love someone’s repository and would like to have it in our GitHub account, we fork it so that we can work with it separately.

当我们喜欢某人的存储库并希望将其存储在我们的GitHub帐户中时,我们会对其进行分叉,以便我们可以单独使用它。

When we fork a repository, we get an instance of that entire repository with its whole history. After forking, we can do whatever we want to do without affecting the original version.

派生存储库时,我们将获得整个存储库的实例及其全部历史记录。 分叉之后,我们可以做任何想做的事情而不会影响原始版本。

什么是拉取请求? (What is a pull request?)

Pull requests are the way we contribute to group projects or open source projects.

拉取请求是我们为小组项目或开源项目做出贡献的方式。

For instance, a user Harry forks a repository of ThanoshanMV and makes changes to that repository. Now Harry can make a pull request to ThanoshanMV, but it’s up to ThanoshanMV to accept or decline it. It’s like saying, “ThanoshanMV, would you please pull my changes?”

例如,用户Harry派生了ThanoshanMV存储库,并对该存储库进行了更改。 现在,Harry可以向ThanoshanMV发出拉动请求,但这取决于ThanoshanMV接受还是拒绝。 就像在说:“ ThanoshanMV,请您拉我的零钱吗?”

贡献意味着什么 (What it means to contribute)

Not only can we contribute to an open source project with code, but we can also contribute in many other ways. Some of these ways are described below.

我们不仅可以使用代码为开源项目做出贡献,而且还可以通过许多其他方式做出贡献。 这些方法中的一些描述如下。

As IT firm’s hacktitude starting guide says, we can contribute to an open source project in the following ways:

正如 IT公司的hacktitude入门指南所说,我们可以通过以下方式为开源项目做出贡献:

  1. Designing: You can construct the layouts of a project to improve its usability, improve the project’s navigation and menu based on user research programs, create art for logos or t-shirts, and provide style guides for the project.

    设计:您可以构造项目的布局以提高其可用性,根据用户研究程序改善项目的导航和菜单,创建徽标或T恤的艺术品,并提供项目的样式指南。
  2. Writing: You can write and improve the project’s documentation or translate the documentation, start a newsletter for the project or write tutorials for the project and curate highlights from the mailing list, or curate a folder of examples showing how the projects are used.

    撰写:您可以撰写和完善项目的文档或翻译文档,为该项目撰写新闻稿,或为该项目编写教程,并从邮件列表中选择要点,或选择一个文件夹示例以显示如何使用项目。
  3. Organizing: You can link duplicate issues, suggest new issue labels, suggest to close old open issues and ask questions on recently opened issues to move the discussion forward.

    整理:您可以链接重复的问题,建议新的问题标签,建议关闭旧的未解决问题,并就最近开放的问题提出问题,以推动讨论的进行。
  4. Help others: Answer questions on open issues, review code on other people’s submissions and offer to mentor another contributor.

    帮助他人:回答有关未解决问题的问题,查看他人提交的代码,并指导其他贡献者。
  5. Coding: Help solve any open issues, ask if you can provide any new features and improve tooling and testing.

    编码:帮助解决所有未解决的问题,询问您是否可以提供任何新功能并改善工具和测试。

让我们提出第一个请求请求! (Let’s make our first pull request!)

If you’re not very familiar with Git & GitHub, please go review .

如果您对Git和GitHub不太熟悉,请查看 。

1.分叉存储库 (1. Fork the repository)

Fork the repository by clicking the fork button on the top of the page. This will create an instance of that entire repository in your account.

通过单击页面顶部的fork按钮来分叉存储库。 这将在您的帐户中创建整个存储库的实例。

2.克隆存储库 (2. Clone the repository)

Once the repository is in your account, clone it to your machine to work with it locally.

将存储库放入您的帐户后,将其克隆到您的计算机上以在本地使用它。

To clone, click on the clone button and copy the link.

要克隆,请单击“克隆”按钮并复制链接。

Open the terminal and run the following command. It will clone the repository locally.

打开终端并运行以下命令。 它将在本地克隆存储库。

$ git clone [HTTPS ADDRESS]

Now we have set up a copy of the master branch from the main online project repository.

现在,我们已经从主要的在线项目存储库中建立了master分支的副本。

We need to go to that cloned directory by running this command:

我们需要通过运行以下命令转到该克隆目录:

$ cd [NAME OF REPOSITORY]

3.创建一个分支 (3. Create a branch)

It’s good practice to create a new branch when working with repositories, whether it’s a small project or contributing to a group's work.

无论是小型项目还是对小组的工作有所帮助,在存储库中创建一个新分支都是一个好习惯。

Branch name should be short and it should reflect the work we’re doing.

分支名称应该简短,并且应该反映我们正在做的工作。

Now create a branch using the git checkout command:

现在使用git checkout命令创建一个分支:

$ git checkout -b [Branch Name]

4.进行更改并提交 (4. Make changes and commit them)

Make essential changes to the project and save it.

对项目进行必要的更改并保存。

Then execute git status , and you’ll see the changes.

然后执行git status ,您将看到更改。

Add those changes to the branch you just created using the git add command:

将这些更改添加到使用git add命令刚创建的分支中:

$ git add .

Now commit those changes using the git commit command:

现在,使用git commit命令提交这些更改:

$ git commit -m "Adding an article to week 02 of articles of the week"

5.将更改推送到GitHub (5. Push changes to GitHub)

In order to push the changes to GitHub, we need to identify the remote’s name.

为了将更改推送到GitHub,我们需要确定远程服务器的名称。

$ git remote

For this repository the remote’s name is “origin”.

对于此存储库,远程名称为“ origin”。

After identifying the remote’s name we can safely push those changes to GitHub.

确定了远程服务器的名称后,我们可以安全地将这些更改推送到GitHub。

git push origin [Branch Name]

6.创建拉取请求 (6. Create pull request)

Go to your repository on GitHub and you’ll see a button “Compare & pull request” and click it.

转到GitHub上的存储库,您将看到一个“比较并提取请求”按钮,然后单击它。

Please provide necessary details on what you’ve done (You can reference issues using “#”). Now submit the pull request.

请提供您所做工作的必要详细信息(您可以使用“#”引用问题)。 现在提交拉取请求。

Congratulations! You've made your first pull request.  

恭喜你! 您已经提出了第一个请求请求。

If your pull request is accepted you’ll receive an email.

如果您的请求请求被接受,您将收到一封电子邮件。

7.同步分支的master分支 (7. Sync your forked master branch)

Before submitting any pull requests to the original repository you have to sync your repository to the original one.

在将任何请求请求提交到原始存储库之前,您必须将存储库同步到原始存储库。

Even if you are not going to submit a pull request to the original repository, it’s better to sync with the original repository as some additional features and bug fixes may have been done since you forked the original repository.

即使您不打算向原始存储库提交拉取请求,也最好与原始存储库同步,因为自从您创建原始存储库以来,可能已经完成了一些其他功能和错误修复。

Follow these steps to update/sync those changes to your master branch:

请按照以下步骤将这些更改更新/同步到您的master分支:

  1. First, check which branch you are in.

    首先,检查您所在的分支。
$ git branch

It’ll list all branches and indicates the current or active branch in green.

它会列出所有分支,并以绿色指示当前或活动分支。

2. Switch to the master branch.

2.切换到master分支。

$ git checkout master

3. Add the original repository as an upstream repository.

3.将原始存储库添加为上游存储库。

In order to pull the changes from the original repository into your forked version, you need to add the original Git repository as an upstream repository.

为了将更改从原始存储库提取到派生版本中,您需要将原始Git存储库添加为上游存储库。

$ git remote add upstream [HTTPS]

Here, [HTTPS] is the URL that you have to copy from the owner’s repository.

在此,[HTTPS]是您必须从所有者的存储库中复制的URL。

4. Fetch the repository.

4.提取存储库。

Fetch all of the changes from the original repository. Commits to the original repository will be stored in a local branch called upstream/master.

从原始存储库中获取所有更改。 提交到原始存储库的内容将存储在称为上游/主服务器的本地分支中。

$ git fetch upstream

5. Merge it.

5.合并。

Merge the changes from the upstream/master into your local master branch. This will bring your fork’s master branch into sync with the upstream repository without losing your local changes.

将更改从上游/主服务器合并到本地主服务器分支。 这将使fork的master分支与上游存储库同步,而不会丢失本地更改。

$ git merge upstream/master

6. Push changes to GitHub

6.将更改推送到GitHub

At this point your local branch is synced to the original repository’s master branch. If you want to update the GitHub repository, you need to push your changes.

此时,您的本地分支已同步到原始存储库的master分支。 如果要更新GitHub存储库,则需要推送更改。

$ git push origin master

NOTE: After syncing your forked master branch you can remove that remote if you want to. But you’ll need to update/sync your repository in future too, so it's best practice to keep it.

注意:同步分支的master分支后,您可以根据需要删除该遥控器。 但是将来您也需要更新/同步存储库,因此最好的做法是保留它。

$ git remote rm [Remote Name]

8.删除不必要的分支 (8. Delete the unnecessary branch)

Branches are created for a special purpose. Once that purpose is accomplished, those branches aren’t necessary, so you can delete them.

创建分支是出于特殊目的。 一旦达到该目的,就不需要那些分支,因此可以将其删除。

$ git branch -d [Branch Name]

You can delete the version of it on GitHub, too.

您也可以在GitHub上删除它的版本。

git push origin --delete [Branch Name]

结论 (Conclusion)

GitHub is a powerful tool to control version history. Everyone can contribute to open source projects by making pull requests. Contributions aren’t always code – there are other ways to contribute, too.

GitHub是控制版本历史记录的强大工具。 每个人都可以通过发出请求请求为开源项目做出贡献。 贡献并不总是编写代码–还有其他贡献方式。

Finally, I have to tell you that you shouldn't worry if your pull requests are rejected. Maintainers spend a lot time improving their projects, and they know a lot more about their projects than we do. So don't worry if your request isn't merged.

最后,我必须告诉您,如果您的请求请求被拒绝,您不必担心。 维护人员花费大量时间来改善他们的项目,并且他们比我们更了解他们的项目。 因此,请不要担心您的请求没有合并。

Stay strong, stay positive, and never give up.

保持坚强,保持积极,永不放弃。

― Roy T. Bennett,

―罗伊·T·贝内特(Roy T.Bennett),

This article was originally posted on .

本文最初发布在 。

You can contact and connect with me on .

您可以在与我联系并建立联系。

Keep contributing to the open source world!

继续为开源世界做贡献!

翻译自:

github上拉取项目

转载地址:http://tozzd.baihongyu.com/

你可能感兴趣的文章
C#WebBrowser控件使用教程与技巧收集
查看>>
Git 命令
查看>>
/x00
查看>>
数据加载中……显示框
查看>>
判断Http请求由手机端发起,还是有电脑端发起
查看>>
ATMEL处理器自带USB CDC的Win7驱动问题
查看>>
gcc 4.8.5安装
查看>>
time模块
查看>>
db2相关问题及解决方法
查看>>
三、CSS样式——背景
查看>>
UVa 12299 RMQ with Shifts(线段树)
查看>>
BZOJ 3224: Tyvj 1728 普通平衡树(BST)
查看>>
uml建模工具Rational Rose2003使用笔记1
查看>>
Multiple
查看>>
网页开发学习笔记八: css 盒子模型
查看>>
一道课本题目引发的思考的再补充
查看>>
9.25
查看>>
javascript函数
查看>>
java泛型中<?>和<T>有什么区别?
查看>>
Vue.js——60分钟组件快速入门
查看>>