本文介绍了为开源git存储库做贡献的工作流程是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不承认我从未为开源项目做过贡献,因为我不了解工作流程.我在git文档中浏览了很多次,但发现它太难了.

I have to admit I've never contributed to an open source project because I do not understand the workflow. I've looked around many times at the git documentation but found it too hard.

我已经使用诸如git仓库的Team Foundation Server(TFS)或Visual Studio Team Services(以前是Visual Studio Online)之类的前端向我的客户端发出了对私有仓库的拉取请求.我也可以使用git命令行轻松地在git存储库上单独工作,因为该工作流程很简单.但是我想使用它的命令行来学习git工作流,以为开源项目做贡献.

I have made pull requests to private repositories for my client using a front-end like Team Foundation Server (TFS) or Visual Studio Team Services (was Visual Studio Online) for git repositories. I can also easily work alone on git repositories using the git commandline because that workflow is simple. But I would like to learn the git workflow using its commandline to contribute to open source projects.

我从github文档中阅读了以下文章.我想我有点了解工作流程,但是我不确定,也害怕在其他人的项目中尝试一下.

I read the following articles from the github documentation. I think I kind of know the workflow but I am not sure and I am scared to try it out on someone else's project.

  1. 分叉回购
  2. 同步叉子
  3. 关于请求请求
  4. 关于协作开发模型
  5. 从叉子创建拉取请求
  6. 创建拉取请求
  1. Fork a Repo
  2. Syncing a fork
  3. About pull requests
  4. About collaborative development models
  5. Creating a pull request from a fork
  6. Creating a pull request

我真正需要的是让某人简化一些易于理解的要点中的步骤.

What I really need is for someone to simplify the steps in a few, easy to understand bullet points.

根据我到目前为止的研究,这是我的理解.

From my research so far, here is what I understand.

让我们假设我们想为一个名为 Boo Boo 的假想项目做出贡献,该项目的所有者名为 Baabaa .让我们假设我想为 Boo Boo 做出贡献的人,在 https://www.github.com/Water-Cooler-v2/

Let us assume we want to contribute to an imaginary project named Boo Boo, the owner of which is named Baabaa. Let us assume that I, the person who wants to contribute to Boo Boo, have a github account at https://www.github.com/Water-Cooler-v2/

以下是我知道工作流程的步骤.完成这些步骤后,我不知道该怎么办.

Below are the steps I know the workflow till. After these steps, I don't quite know what to do.

  1. 首先,我从 https://www.github.com/Baabaa/Boo-Boo 到我自己的github帐户中.现在,我在 https:上有自己的 Boo Boo 叉://www.github.com/Water-Cooler-v2/Boo-Boo .

  1. First I fork Boo Boo from https://www.github.com/Baabaa/Boo-Boo into my own github account. Now, I have my own Boo Boo fork at https://www.github.com/Water-Cooler-v2/Boo-Boo.

然后,我将自己的 Boo Boo 克隆到计算机上的文件夹中,如下所示:

Then, I clone my own Boo Boo into a folder on my computer like so:

MrWaterCooler @ WatersComputer MINGW64/c/WaterCooler/MyFolder/$ git clone https://www.github.com/Water-Cooler-v2/Boo-Boo.git

这会将文件夹 MyFolder/Boo-Boo 中我的存储库的本地副本与指向我自己的 origin remote 链接起来叉子,即 https://www.github.com/Water-Cooler-v2/Boo-Boo.git

This links my local copy of the repository in the folder MyFolder/Boo-Boo with the remote named origin that points to my own fork, i.e. at https://www.github.com/Water-Cooler-v2/Boo-Boo.git

然后,我将 Myfolder/Boo-Boo 中的本地存储库也链接到 Baabaa 的远程存储库.为此,我复制了 Baabaa 存储库的网址,然后输入:

Then, I link my local repository in Myfolder/Boo-Boo with Baabaa's remote repository also. I do this by copying the url of Baabaa's repository and typing:

MrWaterCooler @ WatersComputer MINGW64/c/WaterCooler/MyFolder/Boo-Boo$ git remote添加上游https://www.github.com/Baabaa/Boo-Boo.git

接下来,我确认名为 upstream 的新遥控器已链接到:

Next, I verify that the new remote named upstream has been linked to:

MrWaterCooler @ WatersComputer MINGW64/c/WaterCooler/MyFolder/Boo-Boo$ git remote --v

接下来,我通过键入以下内容将所有分支从远程上游提取到计算机的本地存储库中:

Next, I fetch all the branches from the remote upstream into my local repository in my computer by typing:

MrWaterCooler @ WatersComputer MINGW64/c/WaterCooler/MyFolder/Boo-Boo$ git获取上游/主用户

现在,我签出我的本地 master 分支,无论如何默认情况下都会将其签出,但是无论如何我都会将其签出以确保:

Now, I checkout my local master branch, which would anyway be checked out by default, but I'll check it out anyway just to be sure:

MrWaterCooler @ WatersComputer MINGW64/c/WaterCooler/MyFolder/Boo-Boo$ git checkout master

然后,我将对本地存储库中的文件进行一些更改.在这种情况下,我将编辑一个现有文件(下面不显示,因为它不使用任何git命令),然后添加一个名为MyNewFile.txt的新文件.

Then, I'll make some changes to the files in my local repository. In this case, I'll edit an existing file (not shown below because that doesn't use any git commands), and I'll add a new file named MyNewFile.txt.

MrWaterCooler @ WatersComputer MINGW64/c/WaterCooler/MyFolder/Boo-Boo$ touch MyNewFile.txt

现在,我将 upstream/master 分支合并到我自己的 master 分支中.

Now, I'll merge the upstream/master branch into my own master branch.

MrWaterCooler @ WatersComputer MINGW64/c/WaterCooler/MyFolder/Boo-Boo$ git merge上游/主控

然后,这是我不清楚的步骤.我要推吗?去哪里?我自己的叉子(远程原始主控)还是 Baabaa Boo-Boo (远程上游主控)?

And then, now is the step I am not so clear about. Do I push? To where? My own fork (remote origin master) or Baabaa's Boo-Boo (remote upstream master)?

或者,我是否创建拉取请求?

Or, do I create a pull request?

能否请您验证上面列出的前8个步骤的工作流程,然后完成工作?

Could you please validate the workflow for the first 8 steps listed above, and then complete it?

推荐答案

您只需分叉存储库,将其克隆到本地计算机,可以选择创建一个分支并进行更改.您在本地或在自己的仓库中的工作方式真的不重要.您不必使用GitFlow.您可以进行基于Trunk的开发或任何适合您的工作.完成后,将其推送到您自己的存储库中.然后转到GitHub并针对原始存储库打开PR.这里的所有都是它的.

You just fork the repo, clone it to your local machine, optionally create a branch and do your changes. It really doesn't matter how you work locally or in your own repo. You don't have to use GitFlow. You can do Trunk-based development or whatever works for you. When you are done, you push it to your own repo. Then go to GitHub and open a PR against the original repo. That's all there is to it.

关于将原始存储库添加为远程存储库:将原始存储库添加为远程存储库的主要原因是,当您打算使用原始存储库中的更改(合并,重定基,摘樱桃等)来更新fork时.如果您打算对原始文档做一口气,例如修复一些错误,通常就不需要遥控器了.不过,为长期贡献而添加它是有意义的.

Regarding adding the original as a remote: the main reason to add the original repo as a remote is when you intend to update your fork with changes from the original repo (merging, rebasing, cherry-picking, etc). If you just intend to do a one-shot contribution to the original, like fixing some bug, it's usually not necessary to have the remote. It makes sense to add it for long term contributions though.

这篇关于为开源git存储库做贡献的工作流程是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 05:32