git push “远端意外挂断”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12105147/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:24:55  来源:igfitidea点击:

git push " The remote end hung up unexpectedly "

gitbranchpushmasterlinode

提问by JeskTop

I have created a new branch in my local repository and after some commits, I wanted to push it to the remote repository.

我在我的本地存储库中创建了一个新分支,在提交了一些之后,我想将它推送到远程存储库。

git push origin new_branch

git push origin new_branch

I have this error:

我有这个错误:

$ git push origin new_branch

Counting objects: 32, done.

Delta compression using up to 2 threads. Compressing objects: 100% (18/18),done.

Writing objects: 100% (18/18), 5.29 KiB, done. Total 18 (delta 13), reused 0 (delta 0)

Write failed: Broken pipe

fatal: The remote end hung up unexpectedly

fatal: The remote end hung up unexpectedly

$ git push origin new_branch

计数对象:32,完成。

Delta 压缩最多使用 2 个线程。压缩对象:100% (18/18),完成。

写入对象:100% (18/18),5.29 KiB,完成。总计 18 个(增量 13),重复使用 0 个(增量 0)

写入失败:管道损坏

致命:远端意外挂断

致命:远端意外挂断

When I user $ git remote -v

当我使用 $ git remote -v

origin [email protected]:XXX.git (fetch)

origin [email protected]:XXX.git (push)

origin [email protected]:XXX.git(获取)

origin [email protected]:XXX.git(推送)

the git branch

git 分支

fiberead_com$ git branch -a
* new_branch
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/dev
  remotes/origin/master
  remotes/origin/online

nginx.conf

配置文件

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;

    access_log  /var/log/nginx/access.log;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
#    keepalive_timeout  65;
client_header_timeout 3m;
client_body_timeout 3m;
keepalive_timeout 175 120;
client_max_body_size 35m;

    tcp_nodelay        on;


    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

Can anybody help me, please?

有人可以帮我吗?

My git server is in the Linode.I use GITLAB and the other project isn't have this problem.Only a new project ,I user 'git clone' to pull my computer.But when I push the code, something wrong have happen.

我的 git 服务器在 Linode 中。我使用 GITLAB,另一个项目没有这个问题。只有一个新项目,我使用 'git clone' 来拉我的电脑。但是当我推送代码时,发生了一些错误。

I use Nginx.

我使用 Nginx。

And I use '$ git push origin master', have the same problem.

而我使用'$ git push origin master',也有同样的问题。

回答by VonC

That means the http server in charge of listening to the request (here a git push over http) failed to complete.

这意味着负责侦听请求的 http 服务器(这里是 git push over http)未能完成。

  • Either because of a problem on the server:
    Only log of said http server contain the root cause (it can be for instance a message too big for the server to process, or a right issue, or ...).
    Those logs can be in etc/httpd/httpd.conf(Apache), or /var/log/nginx/error.log(NGiNX) or even in gitlab itself.

  • Or because it never received the request, which the OP jesktopconfirms to be the case here:

  • 要么是因为服务器上的问题:
    只有所述 http 服务器的日志包含根本原因(例如,它可能是服务器无法处理的消息太大,或者是正确的问题,或者......)。
    这些日志可以在etc/httpd/httpd.conf(Apache) 或/var/log/nginx/error.log( NGiNX) 中,甚至可以在 gitlab 中。

  • 或者因为它从未收到请求,OP jesktop在这里确认是这种情况:

I found all of log,but the error log are empty.
The problem is the network. Because I am in China and there is a special network here.
So the VPN can solve this problem.

我找到了所有的日志,但错误日志是空的。
问题是网络。因为我在 CN ,这里有专门的网络。
所以VPN可以解决这个问题。

回答by Arun Antony

Try this:

尝试这个:

git push origin feature/new_branch

and also check whether the connection is live or not.

并检查连接是否有效。

回答by MaxPRafferty

To people arriving from google: Six years later and this still periodically happens. I have seen this occur when I inadvertently committed an extremely large binary (et al). It was not sufficient to remove the binary and recommit to resolve the problem; Because of how Git works, the commit containing it originally remained, and so the size also did. The solution was to rebase the offending commit out completely.

对于从谷歌来的人:六年后,这种情况仍然会定期发生。当我无意中提交了一个非常大的二进制文件(等)时,我已经看到了这种情况。删除二进制文件并重新提交解决问题是不够的;由于 Git 的工作方式,包含它的提交最初保留了下来,因此大小也保留了下来。解决方案是将违规提交完全重新设置。

Once I had identified a bad commit as the cause, the solution every time this occurs became clear: git bisect. This pops up for me maybe once or twice a year and not always because of a large file. Once you have ruled out network issues as the other answers here correctly point out, the solution for me is always the same - bisect, remove the offending commit, then you will be able to push.

一旦我确定了错误提交的原因,每次发生这种情况时的解决方案就变得清晰了:git bisect. 这对我来说可能每年出现一两次,并不总是因为文件很大。一旦您像这里的其他答案正确指出的那样排除了网络问题,我的解决方案总是相同的 - 平分,删除有问题的提交,然后您就可以推送了。