1、将Git 本地仓库和 GitHub 上新建的 Repository 关联 并push 本地代码到远程仓库 出现被拒绝错误
git remote add origin git@github.com:mygithubhost/test.git
git push -u origin master 然后出现 Permission denied (publickey)
git本地提交到github远程仓库有两种 认证 ssh 和 https 方式
通过 git bash 命令窗口方式提交 和 androidstudio vcs 方式
通过ssh协议 在和远程仓库建立连接的时候就不用每次都需要输入用户密码
在创建ssh之前先需要检查本地是否已经有了ssh key 输入 ls -al ~/.ssh

如果有 就将ssh添加到ssh事务中 add ssh to ssh agent
首先先确保ssh agent 是运行的 输入 eval $(ssh-agent -s)
然后添加ssh key (id_rsa文件一般在user/user/.ssh/目录下) 输入ssh-add ~/.ssh/id_rsa
出现输入 密码 : 输入不小于四位的密码
如果没有ssh 就创建一个 generate new ssh key
输入命令 ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
然后输入两次相同的不小于四位的密码
得到ssh key 后 就可以进行上面有ssh 添加到 ssh agent 的操作了
最后再复制id_rsa.pub公钥的内容 然后打开你的github 复制粘贴进去 copy public key to github accout
输入命令$ clip < ~/.ssh/id_rsa.pub 把公钥内容复制到粘贴板上

Github settings 下的ssh and gpgs , new ssh key , 然后复制进来就可以了

这样再进行 git push -u origin master 就不会出错了
另外 git push 到 github 上 50M 会收到警告 100M 直接被拒绝
如果通过 as share project to github 上的话

就不要通过ssh了 不要勾选那个选框
如果想要解除 当前本地project和远程github关联

然后删除 工程目录下 的 .git 就可以了
2.
网友评论