You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PULL_REQUEST_TEMPLATE.md中GitHub相对内部仓库链接无法正常跳转

I’ve run into this exact frustration with GitHub’s PR template relative links before! The issue boils down to how GitHub resolves relative paths on the PR compare page—your template’s links are being interpreted relative to the compare URL (/owner/repo/compare/...) instead of the repository root.

Here’s how to fix it, depending on your needs:

  • Option 1: Use a path relative to the PR compare page
    Since the PR page lives at /owner/repo/compare/[base]...[head], you need to traverse up one level to get back to the repository root, then point to your file. Use this format:

    [CONTRIBUTING.md](../blob/main/.github/CONTRIBUTING.md)
    

    Replace main with your repository’s default branch name (like master if that’s what you use). This will correctly resolve to the file in your repo’s default branch.

  • Option 2: Use an absolute repository path
    If you want to avoid worrying about branch names or page context, you can use a path that starts with your repository’s full root path:

    [CONTRIBUTING.md](/owner/repo/blob/main/.github/CONTRIBUTING.md)
    

    This directly targets the file in your repo’s default branch, regardless of where the link is viewed.

  • Why your previous attempts didn’t work

    • /owner/repo/.github/CONTRIBUTING.md: GitHub interprets leading slashes as relative to github.com, not your repo, hence the incorrect jump to https://github.com/.github/CONTRIBUTING.md.
    • .github/CONTRIBUTING.md or ./.github/CONTRIBUTING.md: These resolve relative to the current PR compare page URL, so they append the path to /owner/repo/compare/ instead of the repo root.

内容的提问来源于stack exchange,提问作者Clif

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:06:11