Git提交push报错:HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large解决方案(超详细步骤)
文章目录
前言
提交代码push的时候报错:HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
原因是上传的文件过大,所以会出现以下的错误信息。网上的改法没有用,只能通过使用ssh方式提交才能解决。因此这里给出解决方法。
错误
Total 45 (delta 12), reused 0 (delta 0), pack-reused 0
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
fatal: the remote end hung up unexpectedly
fatal: the remote end hung up unexpectedly
解决方法
如果你已经配置好了ssh密钥,可以直接跳到第四步。
1.检查现有 SSH 密钥
在生成 SSH 密钥之前,您可以检查是否有任何现有的 SSH 密钥。
注: DSA 密钥 (SSH-DSS) 不再受支持。 现有密钥将继续运行,但您不能将新的 DSA 密钥添加到您的 GitHub 帐户。
-
打开 Git Bash。
-
输入
ls -al ~/.ssh
以查看是否存在现有 SSH 密钥:$ ls -al ~/.ssh # Lists the files in your .ssh directory, if they exist
-
检查目录列表以查看是否已经有 SSH 公钥。 默认情况下,公钥的文件名是以下之一:
- id_rsa.pub
- id_ecdsa.pub
- id_ed25519.pub
如果您没有现有的公钥和私钥对,或者不想使用任何可用于连接到 GitHub 的密钥对,则生成新的 SSH 密钥。
如果您看到列出的现有公钥和私钥对(例如 id_rsa.pub 和 id_rsa),并且您希望使用它们连接到 GitHub,则可以将 SSH 密钥添加到 ssh-agent。
提示:如果您收到错误“~/.ssh 不存在”,不要担心! 我们在生成新的 SSH 密钥时会创建它。
2.生成新 SSH 密钥并添加到 ssh-agent
检查现有 SSH 密钥后,您可以生成新 SSH 密钥以用于身份验证,然后将其添加到 ssh-agent。
如果您还没有 SSH 密钥,则必须生成新 SSH 密钥。 如果您不确定是否已有 SSH 密钥,请检查现有密钥。
如果不想在每次使用 SSH 密钥时重新输入密码,您可以将密钥添加到 SSH 代理,让它管理您的 SSH 密钥并记住您的密码。
生成新 SSH 密钥
-
打开 Git Bash。
-
粘贴下面的文本(替换为您的 GitHub 电子邮件地址)。
$ ssh-keygen -t ed25519 -C "your_email@example.com"
**注:**如果您使用的是不支持 Ed25519 算法的旧系统,请使用以下命令:
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
这将创建以所提供的电子邮件地址为标签的新 SSH 密钥。
> Generating public/private ed25519 key pair.
-
提示您“Enter a file in which to save the key(输入要保存密钥的文件)”时,按 Enter 键。 这将接受默认文件位置。
> Enter a file in which to save the key (/c/Users/you/.ssh/id_ed25519):[Press enter]
-
在提示时输入安全密码。 更多信息请参阅“使用 SSH 密钥密码”。
> Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again]
将 SSH 密钥添加到 ssh-agent
将新 SSH 密钥添加到 ssh-agent 以管理密钥之前,应检查现有 SSH 密钥并生成新 SSH 密钥。
如果已安装 GitHub Desktop,可使用它克隆仓库,而无需处理 SSH 密钥。
-
确保 ssh-agent 正在运行。 您可以根据“使用 SSH 密钥密码”中的“自动启动 ssh-agent”说明,或者手动启动它:
# start the ssh-agent in the background $ eval `ssh-agent -s` > Agent pid 59566
-
将 SSH 私钥添加到 ssh-agent。 If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add ~/.ssh/id_ed25519