一、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)
?w=1:忽略空白字符变更
pr/files、commit diff页面,过滤仅空格换行改动,代码评审神器。
https://github.com/xxx/yyy/pull/42/files?w=1
?ts=n修改tab显示宽度
设置tab渲染为n个空格,默认ts=8,常用?ts=4。
https://github.com/xxx/yyy/blob/main/file.go?ts=4
- 行号锚点
#l10#l10‑l20
点击行号自动生成,精准定位单行/多行代码片段。
https://github.com/xxx/yyy/blob/main/main.py#l12 https://github.com/xxx/yyy/blob/main/main.py#l12‑l24
- 永久固定版本链接(y快捷键)
普通blob链接会随分支变动;按y,url切换为/blob/<commit‑sha>/xxx,永久不变的固定快照链接(permalink)。
三、域名替换黑魔法
- github.dev 网页版vs code
仓库页面把github.com→github.dev,浏览器直接打开完整vs code网页编辑器,等价快捷键.(英文句号)。
https://github.dev/user/repo
快捷键:仓库页面英文输入法直接按 . 一键跳转github.dev。
- github1s(第三方,非官方)
https://github1s.com/user/repo
四、compare高级对比url语法
- 分支/提交对比
# 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小技巧
- commit message写
fixes #123,合并pr后自动关闭issue。 - 评论中粘贴带
#lxx代码片段链接,会自动渲染预览代码片段。
七、安全审计场景实用组合
- 拿用户ssh公钥:
https://github.com/{username}.keys - 批量获取提交补丁:遍历commit url拼接
.patch,脚本批量下载分析历史泄露密钥。 ?w=1过滤大量格式化commit,找真实业务改动。- blame加
~绕过.git‑blame‑ignore‑revs看被隐藏的历史提交。
补充注意
.keys只返回用户上传的ssh公钥,不是gpg密钥;gpg密钥需要访问用户设置页面api获取。.patch/.diff仅公开仓库有效;私有仓库需要登录授权。- github.dev 需要登录github账号;github1s第三方不需要登录。
以上就是github隐藏url的技巧分享的详细内容,更多关于github隐藏url方法的资料请关注代码网其它相关文章!
发表评论