Git push报错:HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large

今天下班,提交React Native项目时,git报错了。
HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
原因很明显,请求体太大导致的。
怎么解决呢?有的说设置postBuffer
error: RPC failed; result=22, HTTP code = 411 fatal: The remote end hung up unexpectedly

设置完然而并没有解决问题。
后来在Stack Overflow·看到有人说将http协议改成SSH协议提交试试.

Pasted Graphic.png

果然,解决了,而且感觉提交速度也快了

然后说下SSH怎么配吧

先检查看有没有已存在的SSH keys,打开终端

$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist

如果已存在,你会看到以上的输出。
如果不存在,那就使用ssh-keygen命令生成.

$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] #直接回车,使用默认文件地址
Enter passphrase (empty for no passphrase): [Type a passphrase] #可直接回车
Enter same passphrase again: [Type passphrase again]

然后你会在~/.ssh/文件夹下看到id_rsa私钥和id_rsa.pub公钥文件.
接下来在git的账户中添加SSH,拷贝id_rsa.pub内容就可以了。

测试有没有添加成功(以GitHub为例,拷贝自github官方文档)

在终端输入

$ ssh -T [email protected]
# Attempts to ssh to github.com

The authenticity of host 'github.com (IP ADDRESS)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?

The authenticity of host 'github.com (IP ADDRESS)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?

Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

OK,SSH keys配置成功了,这是来修改gitremote url
打开终端,进入当前项目下

$ git remote set-url origin [email protected]:GitRepoName.git

接下来提交代码就行了
git push origin master

可能会遇到问题

ssh连接所生成的known_hosts出现的问题

你可能感兴趣的:(Git push报错:HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large)