Github
- 通常情况下ssh连接比http连接更稳定。
- 自23年以后github要求git的远程操作都要通过ssh公私钥进行认证。
公私钥配置成功一段时间后,出现如下Permission denied错误:
git@github.com: Permission denied(publickey).fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.可能是因为本地的ssh-agent误关闭,可以依照官方指南重新启动:
bash 1
2
3eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
- 远程连接Github现在只能通过SSH Access Keys或GPG Keys,Github官方有提供简单的指导文档,其中MacOS的指导没问题,然而根据其指导在Linux服务器上配置时发现会被拒绝,最后发现是访问实际尝试连接HTTP而非SSH服务器导致没用上私钥,因此只要仿照MacOS部分的指导在
~/.ssh/config中写入用户名即可:
1 | |
Github设置
国内有些服务器没办法https连接github服务器,但是可以通过ssh服务器连接。此时可以全局替换
https://github.com/链接为ssh链接,即bash 1
git config --global url."git@github.com:".insteadOf "https://github.com/"这样可以解决
git clone --recursive ...中克隆submodule自动使用https链接导致的无法连接。
Github使用Trick
- 当本地与远端存在需要合并的冲突时,直接
git pull会产生一个merge提交,然而使用git pull --rebase可以让本地新提交的节点直接连在远端节点之后,从而使提交历史只有一条branch,更简洁。
gh使用
- codex等agent可能无法使用gh登录凭据,此时使用
gh auth login --insecure-storage重新登录即可。