【问题标题】:How to add a relative link to a file in a submodule in github markdown?如何在 github markdown 的子模块中添加到文件的相对链接?
【发布时间】:2017-11-04 02:59:10
【问题描述】:

我正在为我的存储库中的 README 文件使用 markdown。

相对链接适用于同一仓库中的文件。

但我想在子模块中链接一个文件(以便显示与子模块相同的版本)。

用例如下:我在external/fancy-lib 中有一个子模块。在我的存储库的 README.md 中,我想添加 "please refer to fancy-lib's [README](external/fancy-lib/README.md) for info about the required packages",但它会生成一个不存在的链接。

从 fancy-lib 的存储库添加到 fancy-lib 的 README 的链接将指向 HEAD,它并不总是包含在我的存储库中的相同版本。 另一方面,每次子模块更新到新版本(git pull)时手动更新链接是一种维护负担。

有什么解决方法吗?

【问题讨论】:

  • 你可以尝试正常的[link](../external/fancy-lib/README.md),但我不确定它是否适用于子模块。
  • 出于某种原因,我假设外部目录高于一级,如果不是,则根本不需要..。另请查看:stackoverflow.com/questions/7653483/…

标签: github markdown github-flavored-markdown


【解决方案1】:

我认为相对链接不会起作用。不过,人们总是可以使用完整的 URL,类似于

![](https://raw.githubusercontent.com/<account>/<name of submodule repo>/README.md)

https://github.com/<account>/<repo>/blob/<hash>/README.md

【讨论】:

  • 我明确提到了relative,因为我想避免这种情况。
  • 顺便说一句,由于子模块指向特定版本,完整的 URL 类似于:https://github.com/&lt;account&gt;/&lt;repo&gt;/blob/&lt;hash&gt;/README.md
猜你喜欢
  • 2011-11-30
  • 2013-01-01
  • 2017-03-18
  • 2015-09-10
  • 2021-11-29
  • 1970-01-01
  • 2017-04-06
  • 2022-09-08
  • 1970-01-01
相关资源
最近更新 更多