Skip to main content

Switch git remote URLs between HTTPS and SSH with ease

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_remote_switch-0.0.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_remote_switch-0.0.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file git_remote_switch-0.0.2.tar.gz.

File metadata

  • Download URL: git_remote_switch-0.0.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for git_remote_switch-0.0.2.tar.gz
Algorithm Hash digest
SHA256 92c4244546d061c836ea9266493c5379f4d63113241fe05b65405821171d0c10
MD5 b54d4b4cf7ebd583dd41b48e39a66975
BLAKE2b-256 cff3052ff9d6448aebe7cdefe808f6b01b83edbe4168174f1e9ebfaa4f0baaba

See more details on using hashes here.

File details

Details for the file git_remote_switch-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for git_remote_switch-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b27aaff222517b9bb1dae041cea13be70ece3cc01e8a5238d85ad58d4d972f5f
MD5 5232cad9061875f8cfd14e61dcab1655
BLAKE2b-256 6ce4e8a31c526f8c84a44cdb123dc2c27758eae50f65934e703481dcd80a8f8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page