git 如何在 GitHub 上拉取 wiki 页面的请求?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10642928/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:43:29  来源:igfitidea点击:

How to pull request a wiki page on GitHub?

gitgithubwiki

提问by cregox

I saw a wiki page on GitHubthat isn't open for editing. Then I forked the project, edited it on "my end" and tried to do a pull request. It turns out, the wikiisn't in the project, and there isn't a way to commit changes to it.

我在GitHub 上看到了一个未开放编辑的 wiki 页面。然后我分叉了这个项目,在“我的最后”编辑它并尝试做一个拉取请求。事实证明,wiki不在项目中,并且没有办法提交对它的更改。

Other than e-mailing, is there a way to proceed if I want to suggest a change on the wiki in this case?

除了电子邮件之外,如果我想在这种情况下建议在 wiki 上进行更改,还有其他方法可以继续吗?

At this point I found out what seems like an alternativeunder "Questions with similar titles", but I couldn't do the pull request with it yet, and so I'm not sure submodules is a good way for this purpose. I now see I could probably branch it somehow... So is this the way to go?

在这一点上,我在“具有类似标题的问题”下发现了一个替代方案,但我还不能用它来做拉取请求,所以我不确定子模块是否是实现此目的的好方法。我现在看到我可能会以某种方式分支它......所以这是要走的路吗?

采纳答案by Calrion

GitHub doesn't support pull requests for the wiki repository, only the main repository (this is a bit of a shame, IMO, but I can understand it).

GitHub不支持 wiki 存储库的拉取请求,只支持主存储库(这有点遗憾,IMO,但我可以理解)。

Here's an interesting way one project manages community updates to their wiki, while still keeping tight control, as for source code:

这是一个项目管理其 wiki 社区更新的有趣方式,同时仍然保持严格的控制,至于源代码:

My proposed workflow is this:

  1. Manually create a fork of the Taffy wiki on your Github account:
    • Create a new repository on your github account. Let's call it "Taffy-Wiki".
    • Clone the Taffy wiki repo to your local machine somewhere: git clone [email protected]:atuttle/Taffy.wiki.git
    • Remove the original "origin" remote and add your github repo as new "origin" git remote rm originand git remote add origin [email protected]:<YOUR_USERNAME>/Taffy-Wiki.git
  2. Make your proposed changes locally, then push them to your github account: git push -u origin master('-u origin master' only required the first time; afterwards just do git push)
  3. Submit a ticket to the official Taffy issue tracker requesting me to review your changes and merge them in. Please be sure to include a link to your repo and describe what you've changed.
  4. Goto #2

我建议的工作流程是这样的:

  1. 在您的 Github 帐户上手动创建 Taffy wiki 的分支:
    • 在您的 github 帐户上创建一个新存储库。我们称之为“Taffy-Wiki”。
    • 将 Taffy wiki 存储库克隆到本地计算机的某个位置: git clone [email protected]:atuttle/Taffy.wiki.git
    • 删除原始的“origin”远程并将您的 github repo 添加为新的“origin”git remote rm origingit remote add origin [email protected]:<YOUR_USERNAME>/Taffy-Wiki.git
  2. 在本地进行您提议的更改,然后将它们推送到您的 github 帐户:git push -u origin master('-u origin master' 仅第一次需要;之后只需执行git push
  3. 向官方 Taffy 问题跟踪器提交一张票,要求我查看您的更改并将它们合并。请确保包含指向您的存储库的链接并描述您更改的内容。
  4. 转到#2

(From How you can contribute to Taffy documentation.)

(来自 如何为 Taffy 文档做出贡献。)

If it were me, I'd create an issue in the main repository (that is, the one you forked) suggesting an update to the wiki. If issues aren't enabled, then email's about the only other option I can think of.

如果是我,我会在主存储库(即您分叉的那个)中创建一个问题,建议对 wiki 进行更新。如果问题未启用,则电子邮件是关于我能想到的唯一其他选项。

回答by Rob Moffat

I've taken a different approach to this, which is to push exactly the same content into both the main repo and the wiki. This won't be to everyone's tastes, but Risk-Firstis mainly a wiki with a few Jekyll pages in the main repo.

我对此采取了不同的方法,即将完全相同的内容推送到主存储库和 wiki。这不会符合每个人的口味,但Risk-First主要是一个 wiki,在主存储库中有一些 Jekyll 页面。

This means the pull request/fork process works fine. However, after merging a pull-request I have to do the extra step of pulling to my local repo and then pushing to both the main repo and the wiki, which git supports fine with multiple origin URLS:

这意味着拉取请求/分叉过程工作正常。但是,在合并拉取请求后,我必须执行额外的步骤,将拉取到本地存储库,然后推送到主存储库和 wiki,git 支持多个源 URL:

localhost:website robmoffat$ git remote show origin
* remote origin
  Fetch URL: [email protected]:risk-first/website.git
  Push  URL: [email protected]:risk-first/website.wiki.git
  Push  URL: [email protected]:risk-first/website.git
  HEAD branch: master

In order to achieve this, I merged the commits from both repos following this:

为了实现这一点,我合并了两个存储库的提交,如下所示:

How do you merge two Git repositories?

如何合并两个 Git 存储库?

And then push to both repos like this:

然后像这样推送到两个仓库:

Git - Pushing code to two remotes

Git - 将代码推送到两个遥控器

Hope this helps someone.

希望这可以帮助某人。

回答by J?rg

We have found the best solution for the problem so far in https://devonfw.com:

到目前为止,我们已经在https://devonfw.com 中找到了该问题的最佳解决方案:

  1. Put your documentation into the git repository together with the code inside a documentation folder.
  2. Extend your travis-ci build with some magic that stages all changes from that documentation folder with transformations applied to the wiki git. See last example link below.
  3. Consider the wiki as read-only view on the documentation. Please note that with github.com you can still view and directly edit the files in the documentation folder. So you still can fix typos within the browser within seconds (even as PR without permissions on the repo) - just not via the wiki.
  4. When a contributor forks, he also has the documentation with the code. He can change both in one PR and all gets reviewed in the same process so after merge Code and Doc remains in sync. Still you have the nicer UX for reading documentation in the wiki with sidebar, etc.
  1. 将您的文档与文档文件夹中的代码一起放入 git 存储库。
  2. 使用一些魔法扩展您的 travis-ci 构建,该魔法将来自该文档文件夹的所有更改与应用于 wiki git 的转换进行分阶段。请参阅下面的最后一个示例链接。
  3. 将 wiki 视为文档的只读视图。请注意,使用 github.com 您仍然可以查看和直接编辑文档文件夹中的文件。因此,您仍然可以在几秒钟内修复浏览器中的拼写错误(即使 PR 对 repo 没有权限)——只是不能通过 wiki。
  4. 当贡献者分叉时,他也有代码的文档。他可以在一个 PR 中进行更改,并且所有内容都在同一过程中进行,因此在合并后代码和文档保持同步。你仍然有更好的用户体验来阅读带有侧边栏等的 wiki 中的文档。

As we are 100% OSS we love to share our hard efforts to come to this great solution. Here are the links as example:

由于我们是 100% OSS,我们喜欢分享我们为实现这一伟大解决方案而付出的辛勤努力。以下是链接示例:

回答by Gabriel Staples

You can't do a pull request, but you can open an issue, paste a link to your wiki page, and let them merge in your wiki page to their wiki page.

您不能执行拉取请求,但您可以打开一个问题,将链接粘贴到您的 wiki 页面,并让它们在您的 wiki 页面中合并到他们的 wiki 页面。

In short:

简而言之:

They just need to clone your wiki page repo, (git clone YOUR_FORKED_REPO.wiki.git), squash all of your wiki commits into one big commit, then cherry-pick this big squashed commit onto their repo. That will bring in all of your wiki changes into their wiki.

他们只需要克隆您的 wiki 页面存储库,( git clone YOUR_FORKED_REPO.wiki.git),将您的所有 wiki 提交压缩到一个大提交中,然后将这个大压缩的提交挑选到他们的存储库中。这会将您所有的 wiki 更改都带入他们的 wiki。

Full instructions:

完整说明:

(COPIED FROM Larry Botha's github gist HERE: https://gist.github.com/larrybotha/10650410):

(从 Larry Botha 的 github gist 复制过来:https: //gist.github.com/larrybotha/10650410 ):

----------START OF COPY-PASTE FROM THE ABOVE GITHUB GIST------------

----------从上面的 GITHUB GIST 开始复制粘贴------------

Merge Wiki Changes From A Forked Github Repo

合并来自分叉 Github 存储库的 Wiki 更改

This is inspired (or basically copied) from How To Merge Github Wiki Changes From One Repository To Another, by Roman Ivanov, and serves to ensure that should something happen to the original article, the information remains nice and safe here.

这是由 Roman Ivanov从How To Merge Github Wiki Changes From One Repository 到另一个的启发(或基本上复制),用于确保如果原始文章发生某些事情,信息在这里保持良好和安全。

Terminology

术语

OREPO: original repo - the repo created or maintained by the owner

OREPO:原始回购 - 由所有者创建或维护的回购

FREPO: the forked repo that presumably has updates to its wiki, not yet on the OREPO

FREPO: 分叉的 repo 可能已经更新了它的 wiki,还没有在OREPO 上

Contributing

贡献

Should you want to contribute to the wiki of a repo you have forked, do the following:

如果您想为已分叉的存储库的 wiki 做出贡献,请执行以下操作:

  • fork the repo
  • clone only the wiki to your machine: $ g clone [FREPO].wiki.git
  • make changes to your local forked wiki repo
  • push your changes to GitHub
  • 分叉回购
  • 仅将 wiki 克隆到您的机器: $ g clone [FREPO].wiki.git
  • 对您本地的分叉 wiki 存储库进行更改
  • 将您的更改推送到 GitHub

Once you are ready to let the author know you have changes, do the following:

准备好让作者知道您有更改后,请执行以下操作:

  • open an issue on OREPO
  • provide a direct link to your wiki's git repo for ease of merging: i.e. [FREPO].wiki.git
  • OREPO上打开一个问题
  • 提供指向您 wiki 的 git repo 的直接链接以便于合并:即 [ FREPO].wiki.git

Merging Changes

合并更改

As the owner of OREPO, you have now received a message that there are updates to your wiki on someone else's FREPO.

作为OREPO的所有者,您现在收到一条消息,指出您的 wiki 在其他人的FREPO上有更新。

If wiki changes are forked from latest OREPOwiki, you may do the following:

如果 wiki 更改是从最新的OREPOwiki分叉出来的,您可以执行以下操作:

$ git clone [OREPO].wiki.git
$ cd [OREPO].wiki.git

# squashing all FREPO changes
$ git pull [FREPO].wiki.git master

$ git push origin master

If OREPOwiki is ahead of where FREPOforked from, do the following:

如果OREPOwiki 位于FREPO分叉的位置之前,请执行以下操作:

$ git clone [OREPO].wiki.git
$ cd [OREPO].wiki.git
$ git fetch [FREPO] master:[FREPO-branch]
$ git checkout [FREPO-branch]

#checkout to last OREPO commit
$ git reset --hard [last-OREPO-commit-hash]

# do massive squash of all FREPO changes
$ git merge --squash HEAD@{1}
$ git commit -m "Wiki update from FREPO - [description]"
$ git checkout master

# cherry-pick newly squashed commit
$ git cherry-pick [OREPO-newly-squashed-commit]
$ git push

----------END OF COPY-PASTE FROM THE ABOVE GITHUB GIST------------

----------从上面的 GITHUB GIST 复制粘贴结束------------

回答by Igor Stoppa

If you are ok to have a single page long document (I actually like it more), you can hiHyman the README.MDand put the content of the wiki there.

如果你可以拥有一个单页长的文档(我实际上更喜欢它),你可以劫持README.MD并将维基的内容放在那里。

Not only it will be tracked as part of the normal repository, it will also be displayed on the home page.

它不仅会作为普通存储库的一部分进行跟踪,还会显示在主页上。

It can be made to start with a quick reference and then get into more detailed description/instructions, so that the regular users will hit first the more generic information.

可以从快速参考开始,然后进入更详细的描述/说明,以便普通用户首先找到更通用的信息。