GitHub · GitLab · Any Git Host

The right key.
The right commit author.

Different platforms. Different identities.不同平台,用不同身份。

Set up each Git identity once. sshift handles SSH keys and commit author settings for matching repositories, so you can keep using Git as usual. 配置一次身份,sshift 就会为匹配的仓库使用对应的 SSH key、提交姓名和邮箱。之后照常使用 Git。

Install sshift

curl -fsSL https://th1humble.github.io/sshift/install.sh | sh

macOS & Linux · Git 2.36+ · 中文文档

$ sshift add
? Platform   GitLab
? Commit email   work@example.com
 
✓ SSH key routed to gitlab.company.com
✓ Commit author set to Work Name
 
$ git commit -m "ship it"
[main 7ab31c2] ship it
Author: Work Name <work@example.com>
 

What sshift solves解决什么问题

Add another Git host without starting over.

Already using GitHub? Add GitLab or your company's Git server without changing what already works.

GitHub 已经配好了?直接添加 GitLab 或公司 Git 服务,不用重新折腾现有配置。

Use the right commit identity.

Personal projects use your personal email. Work repositories use your work email. No need to switch Git configs before every commit.

个人项目用私人邮箱,公司项目用工作邮箱。不用每次提交前手动切换 Git 配置。

Use the right SSH key.

Each Git host gets its own SSH key. Need multiple accounts on the same platform? Use separate SSH aliases.

不同 Git 平台使用各自的 SSH key。同一个平台有多个账号,也可以通过 SSH 别名区分。

Four commands.就四个命令。

Start with sshift add. Add your public key to the Git platform, and you're ready to go.先运行 sshift add,把公钥添加到对应的 Git 平台,就可以正常使用了。

sshift add
Add a Git identity, choose or generate an SSH key, and set your commit name and email.添加 Git 身份,选择或生成 SSH key,设置提交姓名和邮箱。
sshift add --edit <name>

Edit an existing identity using the same wizard.修改已有身份,还是同一个向导。

sshift doctor
Check which SSH key and commit identity your current repository uses.检查当前仓库使用的 SSH key 和 Git 提交身份。
sshift doctor --fix

Fix configuration issues or migrate existing repository-level author settings.修复配置问题,或迁移旧仓库中单独设置的提交身份。

sshift list
Show configured identities, Git hosts, commit authors, and configuration status.查看已配置的身份、Git 平台、提交作者及配置状态。
sshift rm <name>
Remove an identity and its routing rules. Your SSH key files won't be deleted.删除身份及对应的匹配规则,不会删除本地 SSH key 文件。

Existing repositories with local author overrides may need a one-time sshift doctor --fix.如果旧仓库单独设置过提交姓名或邮箱,可能需要运行一次 sshift doctor --fix。