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.com → github.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第三方不需要登录。
相关推荐
奥德元1 小时前
XiaoMate功能介绍: 让桌宠帮你分析你的桌面屏幕
github
TunerT_TQ1 小时前
【开源评测】dots:自带浏览器的 Web AI Agent——C++ 级反检测路径的工程取舍与争议
github
Maynor在掘金1 小时前
1.9 万 Star 的 Hypit:让 AI Agent 帮你“一键复刻”爆款视频,保姆级上手教程
vue.js·github
嘎嘎风2 小时前
MiniMind 学习笔记之 05 从 768 维到下一个 token
github·源码阅读
高频因子挖掘机2 小时前
盘中筛选要同时看价格和盘口?按需分层比“一次全拿”更好维护
后端·github·api
谁在黄金彼岸2 小时前
2026年第40周GitHub趋势周报
github
Daniel_1232 小时前
轻量级站点监控面板 LightPing 开源啦
前端·后端·github
想风2 小时前
A/B 测试怎么做?独立站转化率优化的完整实操步骤
前端·后端·github
miofly2 小时前
Opus 5.5 智能体发现两种室温磁性半导体候选材料,其中一种已有实验验证
开源·github
miofly4 小时前
GitHub 今日推荐|SCSKiller:游戏着色器预编译消除卡顿
开源·c#·github