异常:
fatal: could not read from remote repository fatal: Authentication failed for 'http://git.example.com/example/master.git/'所在公司使用Git版本管理工具,由于以前用的都是SVN,所以不是很熟悉,公司用一个Git账号,个人有一个GitHub账号,我就想配置两套账号,然后就出现了上面的异常。
配置好了Git的SSH,相应的地方添加了Key。 Git Bash处于当前Git目录下
ssh-keygen -t rsa -C “example@163.com”然后找到C:\Users\Administrator.ssh\id_rsa.pub,将里面的Key添加到Git SSH Key中,然后我发现使用的时候还是需要输入账号密码(因为我之前用Eclipse通过http下载的源码),也没有深究为什么还要输入账号和密码。
1.生成SSH,及上面的命令,注意”id_rsa.pub”这个是默认名,记得改。我的是 “id_rsa_github.pub” 2.添加自己的config文件,在同一目录下
Host github.com HostName github.com User xukai IdentityFile ~/.ssh/id_rsa_github Host git.example.com HostName git.example.com User xukai1 IdentityFile ~/.ssh/id_rsa3.切换到SSH协议 GitHub的Repository我是在本地电脑通过GitHub Desktop创建的。走的也是http协议,修改为SSH
git remote -v //查看详细 git remote set-url origin https://github.com/USERNAME/REPOSITORY_2.git ssh -T git@github.com最后一行是测试SSH是否配置成功,成功会显示username。
通过上面的GitHub测试,我打算把公司账号Git的问题解决一下,将协议切换到SSH,然后pull,就出现了标题上的问题,开始以为是因为我配置了两个账号的问题,然后把两个账号的配置文件ctrl+x,backup。 从头来过,重新配置SSH,生成Key,添加Key,pull,不行,clone,不行; 重启电脑 从头来过,重新配置SSH,生成Key,添加Key,pull,不行,clone,不行。崩溃了~ 测试了一下
ssh -T git@git.example.com我的账号显示Welcome,SSH配置是对的! 使用GitHub Desktop进行clone,pull都没问题,于是我怀疑了Git Bash了。
原因是因为Git for Windows这个软件的Bug。Cannot pull/fetch/clone/push with Git for Windows 2.14 over SSH 升级软件就好了。
git --version // 查看当前Git Bash版本我的之前是git version 2.14.1.windows.0 下载了一个新版本git version 2.14.1.windows.1,完美运行~ 官方链接:Gitlab 其他: https://stackoverflow.com/questions/45532727/unable-to-clone-pull-push-a-repository-with-git-for-windows-2-14-over-ssh https://stackoverflow.com/questions/29588258/gitlab-shell-disallowed-command *Git For Windows开源的