今天下班,提交React Native項(xiàng)目時(shí),git報(bào)錯(cuò)了。
HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
原因很明顯,請(qǐng)求體太大導(dǎo)致的。
怎么解決呢?有的說(shuō)設(shè)置postBuffer,
error: RPC failed; result=22, HTTP code = 411 fatal: The remote end hung up unexpectedly
設(shè)置完然而并沒(méi)有解決問(wèn)題。
后來(lái)在Stack Overflow·看到有人說(shuō)將http協(xié)議改成SSH協(xié)議提交試試.

Pasted Graphic.png
果然,解決了,而且感覺(jué)提交速度也快了
然后說(shuō)下SSH怎么配吧
先檢查看有沒(méi)有已存在的SSH keys,打開(kāi)終端
$ ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
如果已存在,你會(huì)看到以上的輸出。
如果不存在,那就使用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] #直接回車(chē),使用默認(rèn)文件地址
Enter passphrase (empty for no passphrase): [Type a passphrase] #可直接回車(chē)
Enter same passphrase again: [Type passphrase again]
然后你會(huì)在~/.ssh/文件夾下看到id_rsa私鑰和id_rsa.pub公鑰文件.
接下來(lái)在git的賬戶(hù)中添加SSH,拷貝id_rsa.pub內(nèi)容就可以了。
測(cè)試有沒(méi)有添加成功(以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配置成功了,這是來(lái)修改git 的remote url
打開(kāi)終端,進(jìn)入當(dāng)前項(xiàng)目下
$ git remote set-url origin git@example.com:GitRepoName.git
接下來(lái)提交代碼就行了
git push origin master