Idea git 提交(push) github失败的原因和解决办法

1.没有配置公开密钥到github

这个配置好密钥就行了。

执行命令
这个会给整个电脑添加
ssh-keygen -o
或者给具体邮箱添加
ssh-keygen -t rsa -C "这里换上你的邮箱"
通过git config --globle --list 查看git信息

可以指定目录也可以选择默认。默认是 user/.ssh/id_rsa.
默认会生产两个文件id_rsa和id_rsa.pub
我们需要把id_rsa.pub放到github上。

Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Administrator/.ssh/id_rsa): g:\rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in g:\rsa.
Your public key has been saved in g:\rsa.pub.

设置github setting->ssh.

2.不小心勾选了Push tag选项

有时候因为忘了要不要勾选下面这个选项,就不小心勾上。勾选这个选项后会导致提交失败。默认是没有勾选的。
在这里插入图片描述

3.git命令操作失误

比如通过命令行设置上流地址什么的。
你没有使用正确的参数,或者你什么地方设置错了。如果你是个新项目,可以直接删了.git文件(历史都会丢失),然后通过Idea提供的share to github功能自动和github绑定。如果是老项目就重新设置一遍。

猜你喜欢

转载自blog.csdn.net/ScottePerk/article/details/126754156