git 分叉和重命名 GitHub 项目时的最佳工作流程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5661405/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best workflow when forking and renaming a GitHub project
提问by Nic Strong
I am trying to figure out the best workflow for working with a fork of an existing opensource project in Github. I want to take an existing project and make significant changes to it, in this case to port it to android and add specific android only functionality. I would like to satisfy the following:
我正在尝试找出使用 Github 中现有开源项目的分支的最佳工作流程。我想采用现有项目并对其进行重大更改,在这种情况下将其移植到 android 并添加特定的 android 功能。我想满足以下几点:
- Be able to pull changes from their public repo to the new android port as the original code is updated.
- Be able to sumbit changes (via pull requests) to the orginal project when I fix bugs that aren't just applicable to the android port.
- Have a seperate renamed version of the project to make it clear that it is a Android port. I looked at renaming a fork and Github gave me huge warnings about doing this.
- 随着原始代码的更新,能够将更改从他们的公共存储库中提取到新的 android 端口。
- 当我修复不仅适用于 android 端口的错误时,能够向原始项目提交更改(通过拉取请求)。
- 有一个单独的项目重命名版本,以明确它是一个 Android 端口。我看着重命名一个叉子,Github 给了我关于这样做的巨大警告。
My initial thoughts are I would fork the original project then fork and rename my fork to give me the following repos:
我最初的想法是我会 fork 原始项目,然后 fork 并重命名我的 fork 以给我以下 repos:
original-author/projectA
nicstrong/projectA
nicstrong/projectA-android
This would allow me to work on my local repo local/projectA-android push changes to nicstrong/projectA-android. Then to update from the orginal project I could rebase nicstrong/projectA to the latest from original-author/projectA then fetch/merge from nicstrong/projectA to local/projectA-android.
这将允许我处理我的本地存储库 local/projectA-android 将更改推送到 nicstrong/projectA-android。然后从原始项目更新,我可以将 nicstrong/projectA 重新绑定到原始作者/projectA 的最新版本,然后从 nicstrong/projectA 获取/合并到 local/projectA-android。
My questions are:
我的问题是:
- I am quite new to the whole Git thing. Does this seem like a good approach? Or is there a better workflow for handling this scenerio?
- How would I handle pushing from projectA-android back to nicstrong/projectA so I can setup pull request for the original project?
- 我对整个 Git 事情很陌生。这看起来是一个好方法吗?或者是否有更好的工作流程来处理这个场景?
- 我将如何处理从 projectA-android 推送回 nicstrong/projectA 以便我可以为原始项目设置拉取请求?
采纳答案by VonC
1/ Yes, that seems the safest approach, as any modification you end up back-porting in nicstrong/projectA
will be in a project with the same structure as original-author/projectA
.
That means pull requests will be easier to organize, since you will be in a project mirroring the original author's project.
1/ 是的,这似乎是最安全的方法,因为您最终向后移植的任何修改nicstrong/projectA
都将在与original-author/projectA
.
这意味着拉取请求将更容易组织,因为您将处于一个反映原始作者项目的项目中。
2/ If you have massive refactoring going on in nicstrong/projectA-android
, I would make a backport
branch, carefully merge or cherry-pick what you need from the numerous changes to the backport
branch, and then push that branch to nicstrong/projectA
.
(which means you have added nicstrong/projectA
as a remote of nicstrong/projectA-android
)
2/ 如果您在 . 中进行大规模重构nicstrong/projectA-android
,我会创建一个backport
分支,从对backport
分支的众多更改中仔细合并或挑选您需要的内容,然后将该分支推送到nicstrong/projectA
.
(这意味着您已添加nicstrong/projectA
为 的遥控器nicstrong/projectA-android
)
回答by Jordan Scales
The name of a git repository is heavily dependent on the name of the remote. Go ahead and clone it, then just add a new remote (by a different name) and begin pushing there. At that point, of course, you can go ahead and change the name of the project directory without issue.
git 存储库的名称在很大程度上取决于远程名称。继续克隆它,然后添加一个新的遥控器(使用不同的名称)并开始推送。那时,当然,您可以继续更改项目目录的名称,而不会出现问题。