github-problem fixes
git pull拉取成功后,本地代码未更新
依次运行:
git add .
git commit -m 'backup'
git stash
继续pull:
git pull origin 分支名
登陆不上github
主要参考以下博客:
https://blog.youkuaiyun.com/qq_36977697/article/details/106710031
填错commit信息
如果填错commit信息但还没有push,还有修改机会。
git commit --amend
使用上述代码编辑commit信息,:wq保存并退出,之后继续push
push失败
已添加公钥但push失败
could not read from remote repository
环境:
本例window10下载使用Git Bash
客户端
1.命令
ssh-keygen -t rsa -C 邮箱地址
例如: ssh-keygen -t rsa -C youremail@163.com
本命令提示输入信息,回车即可
2.命令
ssh -v git@github.com
3.命令
ssh-agent -s
4.命令
eval `ssh-agent -s`
5.命令
ssh-add ~/.ssh/id_rsa_github
//这里对应的改成自己的id_rsa文件名,默认是id_rsa
6.在本例生成的id_rsa.pub在C:\Users\ 用户名
\.ssh
7.在github账号下设置
1>.进入github账号,
2>.在settings页面,找到SSH and GPG keys
3>.点击SSH keys 新建SSH keys
4>.填写title(自定义名称),
5>.将id_rsa.pub里的内容复制到Key中
6>.点击Add SSH Key,完成
如图:
注意:
在C:\Users\lenovo.ssh下有id_rsa和id_rsa.pub
需完整复制id_rsa.pub内容
否则可能报错:
Key is invalid. It must begin with ‘ssh-ed25519’, ‘ssh-rsa’, ‘ssh-dss’, ‘ecdsa-sha2-nistp256’, 'ecds…
8.验证命令
ssh -T git@github.com
connection refused
fatal: unable to access ‘https://github.com/dokdzym/LeetCode.git/’: Failed to connect to 127.0.0.1 port 12639: Connection refused
解决方法:
键入env|grep -i proxy
,看到有多个代理
键入unset http_proxy
和unset https_proxy
将代理取消,恢复正常
问题发现:
每次打开新的git bash都需要重新unset一次代理,否则会refused。并且一些app出现异常(登录不上、加载不了图片等)
后来发现是环境变量里设置了http_proxy 和 https_proxy,删除,重启之后一切正常。