今天下班,提交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协议
提交试试.
果然,解决了,而且感觉提交速度也快了
然后说下SSH怎么配吧
先检查看有没有已存在的SSH keys,打开终端
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
如果已存在,你会看到以上的输出。
如果不存在,那就使用ssh-keygen
命令生成.
$ ssh-keygen -t rsa -C "your_email@example.com"
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 git@github.com
# 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配置成功了,这是来修改git
的remote url
打开终端,进入当前项目下
$ git remote set-url origin git@example.com:GitRepoName.git
接下来提交代码就行了
git push origin master