Git
解决SSL问题
Windows中可能出现此问题:
fatal: unable to access 'https://github.com/x/y': schannel: next InitializeSecurityContext failed: Unknown error (0x80092013)
或:
fatal: unable to access 'https://github.com/ScoopInstaller/Scoop/': schannel: next InitializeSecurityContext failed: CRYPT_E_REVOCATION_OFFLINE (0x80092013)
将后端切换为OpenSSL即可:
git config --global http.sslBackend "openssl"
SSH配置
生成公私密钥:
ssh-keygen -t ed25519 -C "1426652334@qq.com"
然后配置SSH配置(~/.ssh/config
),添加对Github的私钥指定:
Host github.com
Hostname github.com
User git
IdentityFile ~/.ssh/github_id_ed25519
配置全局代理
添加两个全局配置:
git config --global http.proxy "http://127.0.0.1:46251"
git config --global https.proxy "http://127.0.0.1:46251"
配置特定代理
通过SSH配置进行,例如GitHub,添加ProxyCommand nc -v -x 127.0.0.1:46721 %h %p
即可:
Host github.com
Hostname github.com
User git
IdentityFile ~/.ssh/github_id_ed25519
ProxyCommand nc -v -x 127.0.0.1:46721 %h %p
修改历史Commit信息
如果要修改一次commit的信息,需要rebase到该commit的前面的commit上,这也很好理解,我们commit是在目前状态提交的,提交后才成为一个新的commit,要修改这个commit,自然要先到未提交之前了。
git rebase -i HASH
会出现该commit之后的所有commit信息:
pick 864886e update version
pick 6000ccf Update Usage documents and workflow file
pick 74f9caf Bug fix: control --ls would panic when client >= 2
pick 42fb10e Mix Socks support
pick 263a306 Readme update
pick 21a3126 bugfix panic on unreachable ip
pick 52140e5 support shadowsocks, combine all client to auto-route by mix port
pick da6e87e bugfix(mix pass not work), add devcontainer
将需要修改的commit的pick
改为edit
,然后执行:
git commit --amend --reset-author
--reset-author
是用于重置提交者信息的,如果自己的信息确有变更再加入。
执行后修改对应的commit信息后保存出来,然后恢复回去即可:
git rebase --continue
SSH-Agent On Win
在Windows上,SSH-Agent可能出现问题,原因是Git自带一个OpenSSH,系统又自带一个OpenSSH,这导致了SSH-Agent添加到了默认系统的OpenSSH;而Git自带的OpenSSH无法获取到agent的信息,从而鉴权失败。
解决方案,添加环境变量GIT_SSH
:
$env:GIT_SSH = "C:/Windows/System32/OpenSSH/ssh.exe"