Skip to main content

git-remote-switch

一键切换 Git Remote URL:HTTPS ↔ SSH

Version Python License


背景

在国内网络环境下,访问 GitHub 等平台时 HTTPS 方式经常超时或失败,切换到 SSH 可以解决问题;而在公司内网或需要代理时,又可能需要切回 HTTPS。手动改 URL 很麻烦,于是有了这个工具。

安装

pip install git-remote-switch
# 或者
pipx install git-remote-switch

对应的 pypi 的地址:https://pypi.org/manage/project/git-remote-switch

使用

# 切换当前目录的 remote
git-remote-switch
# 或者用简写
grs

# 指定目录
git-remote-switch /path/to/repo

# 预览模式(只看不改)
git-remote-switch --dry-run

工作原理

  • 如果 remote URL 是 HTTPS/HTTP,自动转换为 SSH 格式
  • 如果 remote URL 是 SSH,会让你选择转换为 HTTPS 还是 HTTP

URL 转换示例

原始 URL 转换后
https://github.com/user/repo.git git@github.com:user/repo.git
http://github.com/user/repo.git git@github.com:user/repo.git
git@github.com:user/repo.git https://github.com/user/repo.git(可选择)

许可证

MIT

Metadata

Release files for git-remote-switch 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-remote-switch 0.0.2
File Size Uploaded
git_remote_switch-0.0.2.tar.gz 8.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-remote-switch 0.0.2
File Interpreter ABI Platform
git_remote_switch-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / git_remote_switch-0.0.2.tar.gz

Download URL git_remote_switch-0.0.2.tar.gz
Size 8.6 kB
Tags Source
SHA-256 checksum
How to use checksums
92c4244546d061c836ea9266493c5379f4d63113241fe05b65405821171d0c10
BLAKE2b-256 checksum
How to use checksums
cff3052ff9d6448aebe7cdefe808f6b01b83edbe4168174f1e9ebfaa4f0baaba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / git_remote_switch-0.0.2-py3-none-any.whl

Download URL git_remote_switch-0.0.2-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b27aaff222517b9bb1dae041cea13be70ece3cc01e8a5238d85ad58d4d972f5f
BLAKE2b-256 checksum
How to use checksums
6ce4e8a31c526f8c84a44cdb123dc2c27758eae50f65934e703481dcd80a8f8e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page