GitHub 隐藏URL技巧

一、URL后缀技巧(直接改末尾)

1. .patch / .diff(最常用)

对commit、PR、compare页面,直接追加后缀,返回原始文本diff,可直接git apply打补丁。

复制代码
# 单次提交
https://github.com/xxx/yyy/commit/sha1.diff
https://github.com/xxx/yyy/commit/sha1.patch

# Pull Request
https://github.com/xxx/yyy/pull/123.diff
https://github.com/xxx/yyy/pull/123.patch

# compare对比页面
https://github.com/xxx/yyy/compare/main...dev.diff
https://github.com/xxx/yyy/compare/main...dev.patch
  • .diff:标准git diff格式
  • .patch:带commit元信息,可直接git apply xxx.patch

2. .raw 获取文件原始源码

文件页面末尾改为 /raw,等价页面上的Raw按钮,输出无渲染纯文本源码。

复制代码
原:https://github.com/a/b/blob/main/test.py
改:https://github.com/a/b/raw/main/test.py

3. .blame 代码责任追溯

复制代码
https://github.com/a/b/blame/main/test.py

绕过.git‑blame‑ignore‑revs忽略列表:在commit sha后面加~/blame/sha~/test.py,可以看到被屏蔽的提交记录。

4. gist专属后缀

复制代码
# gist纯文本
https://gist.github.com/user/id.raw
# gist可嵌入HTML页面
https://gist.github.com/user/id.pibb

5. .keys 用户公钥页面

用户主页后加 .keys,直接拿到该用户所有上传的SSH公钥,安全审计常用。

复制代码
https://github.com/username.keys

二、URL Query参数技巧(?xxx=1

  1. ?w=1:忽略空白字符变更
    PR/files、commit diff页面,过滤仅空格换行改动,代码评审神器。

    https://github.com/xxx/yyy/pull/42/files?w=1

  2. ?ts=N 修改Tab显示宽度
    设置tab渲染为N个空格,默认ts=8,常用?ts=4

    https://github.com/xxx/yyy/blob/main/file.go?ts=4

  3. 行号锚点 #L10 #L10‑L20
    点击行号自动生成,精准定位单行/多行代码片段。

    https://github.com/xxx/yyy/blob/main/main.py#L12
    https://github.com/xxx/yyy/blob/main/main.py#L12‑L24

  4. 永久固定版本链接(y快捷键)
    普通blob链接会随分支变动;按y,URL切换为/blob/<commit‑sha>/xxx,永久不变的固定快照链接(permalink)。

三、域名替换黑魔法

  1. github.dev 网页版VS Code
    仓库页面把 github.comgithub.dev,浏览器直接打开完整VS Code网页编辑器,等价快捷键.(英文句号)。

    https://github.dev/user/repo

快捷键:仓库页面英文输入法直接按 . 一键跳转github.dev。

  1. github1s(第三方,非官方)

    https://github1s.com/user/repo

四、Compare高级对比URL语法

  1. 分支/提交对比

    A分支到B分支

    https://github.com/user/repo/compare/main...feature

    跨fork对比:别人仓库的分支 和自己仓库对比

    https://github.com/my/repo/compare/otheruser:theirbranch...mybranch

    时间对比:master一天前 vs 当前master

    https://github.com/user/repo/compare/master@{1.day.ago}...master

    指定日期对比

    https://github.com/user/repo/compare/master@{2026‑01‑01}...master

末尾追加.diff/.patch直接拿diff文本。

五、网页端键盘快捷键(仓库页面)

快捷键 功能
t 快速文件搜索,输入文件名跳转文件
y 切换为commit‑sha永久链接(permalink)
.(句号) 打开github.dev网页VSCode
l 快速跳转到行号
s 聚焦搜索框
g i 跳转到Issues页面
g p 跳转到Pull requests页面
b 切换分支选择框
shift + ←/→ diff页面切换文件

六、提交与Issue小技巧

  1. commit message写 Fixes #123,合并PR后自动关闭issue。
  2. 评论中粘贴带#Lxx代码片段链接,会自动渲染预览代码片段。

七、安全审计场景实用组合

  1. 拿用户SSH公钥:https://github.com/{username}.keys
  2. 批量获取提交补丁:遍历commit url拼接.patch,脚本批量下载分析历史泄露密钥。
  3. ?w=1过滤大量格式化commit,找真实业务改动。
  4. blame加~绕过.git‑blame‑ignore‑revs看被隐藏的历史提交。

补充注意

  • .keys只返回用户上传的SSH公钥,不是GPG密钥;GPG密钥需要访问用户设置页面API获取。
  • .patch/.diff 仅公开仓库有效;私有仓库需要登录授权。
  • github.dev 需要登录github账号;github1s第三方不需要登录。
相关推荐
峰向AI1 小时前
10年开源云盘 Nextcloud:你自己的云,你自己的规则,告别付费
github
灰灰20264 小时前
GitHub 国内下载加速工具合集
github·github下载加速
m4Rk_4 小时前
【论文阅读】Agent 记忆机制(50):PACE——按下一步预测价值动态分配历史记忆粒度
论文阅读·人工智能·学习·开源·github
中科三方7 小时前
DNS解析中的“委派“是什么意思?如何正确配置NS记录?
git·github·dns解析
保持清醒的坐标系7 小时前
腾讯开源 teamai-cli:让全队 AI 工具用同一套"员工手册"
后端·github
赫媒派8 小时前
Cursor Origin:SpaceX 收购后的首个产品,能否挑战 GitHub?
github·ai编程·cursor
深念Y9 小时前
Fork 仓库瘦身指南:从 90MB 到 11MB
git·github·仓库·历史·瘦身·fork·上游
智恒百亿9 小时前
AI服务器涨价15%背后:5090八卡智算服务器的选型与成本分析
大数据·服务器·人工智能·github
鲨鱼辣钊9 小时前
Github Copilot 研发效能提升实战指南
log4j·github·copilot