Git push報(bào)錯(cuò):HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large

今天下班,提交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)修改gitremote 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

可能會(huì)遇到問(wèn)題

ssh連接所生成的known_hosts出現(xiàn)的問(wèn)題

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容