设置全局代理
一、管理
(一)删除
在 Repositories 中 ,点入某一个仓库,然后点 setting ,到最底下,找到 Delete this repository,点击 Delete this repository
Open: Pasted image 20260217193025.png
(二)创建
步骤 1:在 GitHub 创建新仓库
1. 访问 https://github.com/new
2. 仓库名:aiasme
3. 可见性:Private(私有)
4. 不勾选任何选项(README、.gitignore、License)
5. 点击 "Create repository"
Open: Pasted image 20260217193657.png
步骤 2:切换远程仓库
- origin https://gitee.com/hankchy/aiasme.git (fetch)
- origin https://gitee.com/hankchy/aiasme.git (push)
步骤 3:修改远程地址为 GitHub
git remote set-url origin https://github.com/hankchy/aiasme.git
步骤 4:推送到 GitHub
git push origin master --force
(三)在 linux 服务器使用 git
GitHub 2021 年起禁止用密码做 Git 操作,必须用 Token。
你在 Chrome 登录 GitHub 用的是密码,但 git clone 需要的是 Personal Access Token。
生成 Token:
- Chrome 打开 https://github.com/settings/tokens
- 点 Generate new token → Generate new token (classic)
- Note 填 news-server,Expiration 选 No expiration
- 勾选 repo(全部仓库权限)
- 拉到最下面点 Generate token
- 立即复制那串 ghp_xxxxxxxxxxxx(离开页面就看不到了)
然后服务器上重新 clone:
rm -rf /www/news
git clone [https://github.com/hankchy/news.git](https://github.com/hankchy/news.git) /www/news
Username: [hankchy@qq.com](mailto:hankchy@qq.com)
Password: <粘贴刚才复制的 ghp_xxx token>(不是你的 GitHub 密码!)
保存凭据,以后 git pull 不再问
git config --global credential.helper store
浏览器登录用密码,Git 操作用 Token,这是两套不同的认证方式。
二、网络代理
(一)背景
在 Obsidian 知识库中使用 Git 插件同步 GitHub 时,会遇到 HTTPS 连接被阻断的问题(SSL connect error,端口 443 超时)。Ping 能通但 HTTPS 无法连接,是典型的网络封锁现象。
(二)前提条件
本方法依赖 Clash Verge(或其他 Clash 内核的代理软件)已正常运行。Clash Verge 的混合代理端口常用 7890 或 7897,具体以本机实际端口为准。
确认代理端口的方法:
1. 任务管理器 → 找到 verge-mihomo 进程
2. 或打开 Clash Verge 界面查看混合端口设置
(三)Git 代理配置
1. 方法一:全局代理(推荐,所有仓库生效)
适用于 Obsidian 中所有知识库统一走代理的场景:
# 设置全局代理
git config --global http.proxy http://127.0.0.1:7897
git config --global https.proxy http://127.0.0.1:7897
设置后,Obsidian 中所有知识库的 Git 同步均通过代理。
2. 方法二:仅当前仓库生效
如果你只想某个 Obsidian 知识库走代理(进入该知识库根目录执行):
git config http.proxy http://127.0.0.1:7897
git config https.proxy http://127.0.0.1:7897
3. 查看与取消代理
# 查看当前 Git 代理配置
git config --global --get http.proxy
git config --global --get https.proxy
# 取消全局代理
git config --global --unset http.proxy
git config --global --unset https.proxy
# 取消本地仓库代理
git config --unset http.proxy
git config --unset https.proxy
(四)说明
git config --global只影响 Git 本身,不影响 Chrome 等浏览器的网页访问- 如果 Clash Verge 关闭或端口号变动,需要更新对应的代理地址
- 该方法适用于所有基于 HTTPS 协议的 Git 远程仓库(GitHub、GitLab 等)