530

When I tried to run

git push origin master --force

I just got

Counting objects: 2649, done.
Delta compression uses up to 2 threads.
Compressing objects: 100% (1280/1280), done.
error: RPC failed; result=22, HTTP code = 413 | 116 KiB/s   
fatal: The remote end hung up unexpectedly
Writing objects: 100% (2504/2504), 449.61 MiB | 4.19 MiB/s, done.
Total 2504 (delta 1309), reused 2242 (delta 1216)
fatal: The remote end hung up unexpectedly
Everything up-to-date

Is it something to do with not being secure? I tried creating a public key as the answer for Fatal: The remote end hung up unexpectedly and rerunning it, but it still doesn't work. Am I not actually using the key? If so, how do I use it?

DanielLC
  • 5,801
  • 5
  • 18
  • 16
  • please show output of `git remote -v` – CharlesB Mar 06 '13 at 06:59
  • 3
    possible duplicate of [Git fails when pushing commit to github](http://stackoverflow.com/questions/2702731/git-fails-when-pushing-commit-to-github) – CharlesB Mar 06 '13 at 07:01
  • 37
    git config http.postBuffer 524288000 # it works for me – Hari Das Oct 25 '14 at 14:37
  • if you get `error: could not lock config file .git/config: No such file or directory` see http://stackoverflow.com/a/32329453/827525 – niksmac Sep 16 '15 at 04:03
  • 4
    I could not get any of the suggested solutions to work. Then I tried GitKraken. It is one of the few Git programs that doesn't use git.exe. GitKraken could do it. After GitKraken had pushed the repository I could switch back to git.exe and sync without any issues. – lars pehrsson Feb 26 '17 at 10:53
  • 1
    it might be due to network issues – AmiNadimi Jun 06 '17 at 07:21
  • @larspehrsson Please add this as an answers. This solved the problem for me using GitKraken instead, apparently the "official" git package is broken on windows. – aggaton Aug 07 '21 at 18:41
  • A very odd thing for me but leaves a lot of questions. I use Cox cable, I get the same error message when pushing. If I connect to a VPN like mullvad It magically works. Would Cox be limiting or sending my data elsewhere? – Azul May 04 '23 at 04:54
  • I have this error sometimes on wifi. Connecting the Ethernet cable works out for me. – Timothy Jun 26 '23 at 20:17

51 Answers51

843

This is due to git/https buffer settings.

Run this (taken from Git fails when pushing commit to github):

git config http.postBuffer 524288000

Then, run your original command again.

Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
Roman M
  • 8,849
  • 2
  • 15
  • 17
  • 10
    I need the buffer to be higher than 500MB - is that possible? It doesn't seem to make a difference if I make the postBuffer number any higher... – jowie Sep 11 '13 at 13:45
  • Thanks for the link - I sorted the issue by splitting the push into smaller chunks. If I have a problem again I know where to look! – jowie Sep 30 '13 at 08:13
  • This solves my issue as well, I'm guessing it's because a couple of my files went over the default allowed maximum transfer size supported by git? – ffledgling Apr 04 '14 at 08:18
  • As I understand it , git commits as a transaction. sum of all your files were bigger then the http post limit – Roman M Apr 04 '14 at 20:24
  • doesn't solve it for me: git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin develop:develop Pushing to git@github.com:foo/baa.git ERROR: Repository not found. fatal: The remote end hung up unexpectedly Completed with errors, see above – SuperUberDuper Jan 21 '15 at 12:11
  • @SuperUberDuper it looks like you have a different issues. Your ERROR is Repository not found – Roman M Jan 21 '15 at 14:48
  • 27
    Would it be a good idea to use this with `--global`? I deal with large repositories regularly. – DaAwesomeP Feb 02 '15 at 20:55
  • I had a similar problem on Windows 7. After hours of googling, comming accross this post and doubling the buffer size, I discovered it was my antivirus software that was causing the issue – user28864 Feb 15 '17 at 23:36
  • This helps in some cases where the remote end hangs up, but I think in those cases you can see that it fails before all of the objects have been transferred. – mc0e Mar 14 '17 at 05:47
  • issue isn't publicly available anymore :( – shivam13juna Feb 14 '19 at 10:53
  • 5
    @shivam13juna nothing is ever deleted from the internet: :) https://web.archive.org/web/20170119225336/http://github.com/gitlabhq/gitlabhq/issues/3099 – Roman M Feb 17 '19 at 09:06
  • 34
    I ran "git config http.postBuffer 524288000", but still issue not resolved, it still saying the same, the remote end hung up unexpectedly – Narendra Feb 25 '20 at 01:38
  • 3
    @jowie I have written an [answer](https://stackoverflow.com/a/64565533/) attempting to note why this value can be as high as 2000000000 (2 GB), and what else needs to be done to make it work. – Asclepius Oct 28 '20 at 02:16
  • This didn't work for me but the accepted answer did work so please check that out if this didn't work for you as well! I had to first remove and re-add my remote origin which worked. First `git remote rm origin` and then `git remote add origin git@github.com:username/project.git` – Lushawn Sep 01 '22 at 17:38
  • This might be an obscure suggestion, but just in case anyone is using easybuild or lmod, having easybuild modules loaded can cause this error. The solution is to run `module purge` and try again. Everyone else can ignore this comment! – Dan Tenenbaum Sep 22 '22 at 18:49
  • 1
    If using ssh instead of http then type `git config ssh.postBuffer 524288000` before pushing to repo – Gilad Brunfman Jan 03 '23 at 21:56
139

Cause: The default file post size for Git has been exceeded.

Solution: Navigate to repo. Run the following command to increase the buffer to 500MB after navigating to the repository:

git config http.postBuffer 524288000
Mateen Ulhaq
  • 24,552
  • 19
  • 101
  • 135
Chinu
  • 1,399
  • 1
  • 8
  • 2
  • 60
    You can also use `git config ssh.postBuffer 524288000` if posting over ssh instead of http. – John M May 11 '15 at 21:01
  • 9
    For some cases `git config --global http.postBuffer 100000000` – Job M Nov 11 '19 at 13:23
  • I get 'fatal: not in a git directory' after execution of this command – ka3ak Feb 05 '20 at 13:44
  • 3
    @JohnM This option doesn't seem to exist, it's not documented in the man page or https://git-scm.com/docs/git-config – Nobody Feb 10 '20 at 11:58
  • I have written an [answer](https://stackoverflow.com/a/64565533/) attempting to note why the `http.postBuffer` value can possibly be as high as 2000000000 (2 GB), and what else needs to be done to make the push succeed. – Asclepius Oct 28 '20 at 02:29
  • @Nobody this is the version that worked for me – zephyrus Nov 22 '22 at 03:02
119

This looks similar to How do I get github to default to ssh and not https for new repositories. Probably it's worth trying to switch from http protocol to ssh:

$ git remote add origin git@github.com:username/project.git
Community
  • 1
  • 1
Vitalliuss
  • 1,614
  • 1
  • 12
  • 10
  • Why can't I just switch from http to https? – DanielLC Mar 07 '13 at 02:58
  • 16
    bash-3.2$ git remote add origin git@github.com:xxx/xx.git fatal: remote origin already exists. WHY ? – almaruf Nov 03 '14 at 10:36
  • 18
    @almaruf it is because the remote `origin` is already there and you are trying to replace it. git doesn't allow that. So you have to first do `git remote rm origin` then try again. It would work – Alfie Apr 25 '15 at 11:28
  • 2
    make sure you initialise the project if it's a new fresh clone with `git init` – Raul Jul 21 '16 at 09:29
  • you can use either the git protocol over ssh (which requires ssh keys) or the https protocol which requires username and password through a personal access token – I prefer the later – Raul Jul 21 '16 at 09:30
  • The good point of SSH comparing HTTPS is that you can use one ssh key for several repositories and git hostings. I use one key for github, bitbucket and gitlab in despite of different usernames for every hosting. It saves a lot of time for fetch & push operations. – Vitalliuss Sep 19 '16 at 15:51
  • Based on reports at https://bitbucket.org/site/master/issues/4123/fatal-the-remote-end-hung-up-unexpectedly this sometimes helps, but it doesn't work consistently. – mc0e Mar 14 '17 at 05:46
  • Cloning with SSH instead of HTTP works for me. **With SSH I also see a performance increase while cloning** – Vishrant Jul 09 '20 at 02:02
  • My repository size is 70G .I'm use ssh already,but still got the same error – linjiejun Sep 21 '20 at 08:39
  • My repository size is 70G .I'm use ssh already,but still got the same error – linjiejun Sep 21 '20 at 08:39
  • 21
    Could someone explain WHY this would be the solution? As a less experienced github user, this question and the one linked in the answer don't appear to have any connection. I'm hesitant to learn how to do this when there is no logical explanation of why switching to SSH would solve the problem of "remote end hung up unexpectedly" – canderson156 Oct 15 '20 at 13:44
  • In my case, this didn't solve the problem, however, it did bring the underlying error to the surface: `remote: fatal: pack exceeds maximum allowed size (2.00 GiB)`. For some reason, using HTTPS didn't provide that error message during the push and instead would only show `fatal: the remote end hung up unexpectedly`. – dev8675309 Mar 03 '22 at 15:23
59

You might get an error like this

error: could not lock config file .git/config: No such file or directory

that is because you don't have a local .git/config file You can get it working by this command:

git config --global http.postBuffer 524288000
nik7
  • 806
  • 3
  • 12
  • 20
niksmac
  • 2,667
  • 3
  • 34
  • 50
  • 3
    this helped me when trying to clone on a very slow PC inside cygwin - it continued to remote end hung up - until I used this command – serup Apr 05 '17 at 21:52
  • This help me to resolve the "fatal: The remote end hung up upon initial contact" issue. – Karthic.K Jun 05 '17 at 04:53
54

Culprit (in my case):
A high-latency network.

This is not an answer per se but more of an observation that may help others. I found that this error pops up occasionally on high-latency networks (I have to use a Satellite dish for internet access for example). The speed of the network is fine, but the latency can be high. Note: The problem only exists in certain scenarios, but I have not determined what the pattern is.

Temporary mitigation:
I switched networks—I moved to a slower, but lower latency cell network (my phone used as a hotspot)—and the problem disappeared. Note that I can only do this itermittently because my cell connectivity is also intermittent. Plus the bandwidth usage adds costs. I'm also lucky that I have this option available to me. Not everyone does.

I'm sure there is some configuration setting somewhere that makes git—or ssh or curl or whatever times out first—more tolerant of such networks, but I don't know what it is.

A plea to developers:
These kinds of issues are a constant problem for rural populations. Please think of us when you design your systems, tools, and applications. Thank you.

t0dd
  • 651
  • 5
  • 2
  • ssh itself has some tuning options (keepalives etc) but the main tuning options are generally kernel-level and need to be set on both sides (e.g., over on GitHub as well). Kind of a problem. Something I'd like to see for cases like yours is an aggregator (LAGG interface style) that can use both the satellite and the cell phone networks. This is unfortunately far from trivial. – torek Nov 18 '21 at 07:12
  • I used "Network link conditioner" from Xcode's additional tools and applied "3G" profile from my mac machine. I worked :) – Rafat touqir Rafsun Jul 14 '22 at 14:40
47

Other solutions didn't work in my case, doing a garbage collection fixed it for me:

git gc --aggressive

You can try with just git gc first.

nik7
  • 806
  • 3
  • 12
  • 20
Shameen
  • 2,656
  • 1
  • 14
  • 21
  • 42
    This fixed my problem, but it also squashed the detached HEAD changes into a state where merging them became obnoxious (everything was converted to an ADD). I wish I had researched this one more before running it. – MatrixManAtYrService Jul 01 '16 at 03:40
  • This fixed my problem. My problem was (using ssh): $ git push | Enumerating objects: 886, done. | Counting objects: 100% (850/850), done. | Connection to bitbucket.org closed by remote host. | fatal: the remote end hung up unexpectedly | Compressing objects: 100% (831/831), done. | fatal: the remote end hung up unexpectedly – manuelpgs Sep 09 '20 at 02:58
  • Git will exec gc command automaticly before exec push command – linjiejun Sep 21 '20 at 08:45
  • @linjiejun in my case, I could not push until I pulled first, and the pull is where I was getting the error "fatal: Out of memory, malloc failed..." – brethvoice Jul 13 '21 at 15:36
25

Contrary to one of the other answers - I had the problem on push using ssh - I switched to https and it was fixed.

git remote remove origin
git remote add origin https://github.com/user/repo
git push --set-upstream origin master
MikeB
  • 928
  • 9
  • 24
20

If using GitHub, in the repo's directory, run this command to set http.postBuffer to what appears to be its maximum allowable value for GitHub:

git config http.postBuffer 2147483648

If cloning a repo instead using git clone, it can be cloned with the same option:

git clone -c http.postBuffer=2147483648 git@github.com:myuser/myrepo.git /path/to/myrepo

In both cases, the number above is equivalent to 2 GiB. It is however possible that you will need up to this amount of free memory to be able to use this value.

Ensure that each push to GitHub has commits that don't add more than this size of changes. In fact I would keep the commit push size under 1.8 GiB to be safe. This can require dividing a large commit into smaller commits and pushes.

Why this value?

This specific value is used because at least as of the year 2018, this value was documented (archive link) as the push size limit of GitHub:

we don’t allow pushes over 2GB

Why not set lower?

Some prior answers say to set it to 524288000 (500 MiB), but this number seems arbitrary and without merit. Any lower value should work as long as your push size is not larger than the set value.

Why not set higher?

If instead you set the value to higher than 2 GiB, and if your attempted push size is also higher, you can expect the documented error with GitHub:

remote: fatal: pack exceeds maximum allowed size

Asclepius
  • 57,944
  • 17
  • 167
  • 143
15

The following commands might help you...

git config --global http.postBuffer 1048576000
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999
11

Based on the protocol you are using to push to your repo

HTTP

git config --global http.postBuffer 157286400

References:

SSH

Add the following in ~/.ssh/config file in your linux machine

Host your-gitlab-server.com
  ServerAliveInterval 60
  ServerAliveCountMax 5
  IPQoS throughput

References:

Asclepius
  • 57,944
  • 17
  • 167
  • 143
HimalayanCoder
  • 9,630
  • 6
  • 59
  • 60
  • In this answer, `http.postBuffer` is effectively set to 150 MiB. If necessary, one can go higher up to 2 GB as I try to explain in my [answer](https://stackoverflow.com/a/64565533/). – Asclepius Oct 28 '20 at 02:22
  • SSH config just fixed my problem with gitlab.com. Thank you a lot. – Alberto Jan 23 '21 at 20:49
  • How do I do this for GitHub? Is my host github.com? – Giovanni May 09 '21 at 08:41
10

This error can also be thrown through missing write permissions on the repository.


My concrete case went like this:

  1. I created a repo with the root user of my server (via SSH).
  2. I installed a git service and created a git linux user that should manage all git-related action.
  3. By that time, I had forgotten that the repo was created with the root user in the first place, and the git user simply didn't have the file permissions to write anything into the repository.
Loilo
  • 13,466
  • 8
  • 37
  • 47
9

This article have very good explanation and it solved my problem.

git config --global http.postBuffer 157286400

https://confluence.atlassian.com/stashkb/git-push-fails-fatal-the-remote-end-hung-up-unexpectedly-282988530.html

Awais Jameel
  • 1,838
  • 19
  • 14
6

In my case I got this error, when pushing with Intellij Idea.

Here is how I traced down my error and fixed it.

  • enable debug logging within the terminal, which is never a bad idea :)
set GIT_CURL_VERBOSE=1 set GIT_TRACE=1 
  • push via the terminal, not via intellij
git push 
-> fatal: The current branch feature/my-new-feature has no upstream branch.
To push the current branch and set the remote as upstream

Solution was to set the upstream, which must have been gone wrong before:

git push --set-upstream origin feature/my-new-feature
Lama
  • 2,886
  • 6
  • 43
  • 59
6

Even after configuring post buffer the issue was not resolved.

My problem was solved when I changed my wifi network from broadband to my mobile hotspot. This might not be the logically correct answer but it solved the issue.

Make sure you have good internet speed.

Devanshi Modha
  • 359
  • 5
  • 8
  • 1
    Thanks for the note. I'm facing the same issue. It seems that something (firewall?) on the local (wifi) network might somehow break the connection to git servers. The connection is otherwise really good here, so I suspect it might be configuration issue on the (MikroTik) router. – kub1x Apr 09 '21 at 12:55
6

None of the above solutions worked for me, however the commit I was pushing was very large.

Very simply, I split it into two commits and pushed each one separately and it went through instantly.

user11809641
  • 815
  • 1
  • 11
  • 22
  • can you explain how to split the commit? – arilwan Feb 22 '22 at 19:07
  • 1
    @arilwan In my case, there were 5 or 10 files, if I recall correctly, so I committed the first half and pushed it, then committed the second half and pushed that. It went through instantly both times. – user11809641 Feb 23 '22 at 02:40
5

In our case, the problem was a clone that wrote a .git/config file which contained a url entry that was a read only access method. Changing the url from the :// method to the @ method fixed the problem.

Running git remote -v illuminated the issue some.

rayryeng
  • 102,964
  • 22
  • 184
  • 193
Frank P
  • 59
  • 1
  • 1
5

None of the above answers worked for me, but here's what did.

  1. delete .git/ from your project
  2. clone the remote repo to some new location like your desktop:
    git clone https://github.com/foo/bar.git
    
  3. move .git/ from the new location into the old location
  4. re-commit and push your changes
nik7
  • 806
  • 3
  • 12
  • 20
Ben
  • 20,038
  • 30
  • 112
  • 189
4

Another addition, since I encountered this error a different way and Google took me here.

My problem was a mismatch of case; one camelCase and one not. Apparently, GIT stops you doing this without telling you why. So if your branches are different from the remote only in the capitalization, try changing them to be identical.

See: Git: 'Master cannot be resolved to branch' after merge

Community
  • 1
  • 1
Thomas
  • 375
  • 2
  • 10
  • I thought I included all relevant info - it's caused by a case mismatch. I've added a sentence to be more explicit, but this isn't really about the link. Sorry if that wasn't clear. – Thomas Dec 03 '15 at 11:08
4

I solved this issue by repacking:

git repack --max-pack-size=100M -a -d

Go to Repository > Open in command prompt in GitHub Desktop Run the following commands:

set GIT_TRACE=1
set GIT_CURL_VERBOSE=1
git push origin <branch>
Abubakr Elghazawy
  • 977
  • 14
  • 21
3

If you are using git for windows (and you likely are, if you are doing this on a windows machine), and none of the other fixes here worked for you, try going to https://github.com/git-for-windows/git/releases, and getting a version on or after version 2.4.5. Fixed it right up for me.

rrreee
  • 753
  • 1
  • 6
  • 20
3

You probably did clone the repository within an existing one, to solve the problem can simply clone of the repository in another directory and replicate the changes to this new directory and then run the push.

  • we have a beta ansible workflow and rebuilding the site caused exactly this, cloning the repo on top of the other one. Ansible thing to fix but casing a git problem. Thanks :-) – Alejandro Moreno Mar 24 '16 at 10:33
3

Recently I faced the same problem. When cloning a remote repository I got the error as follows:

fatal: the remote end hung up unexpectedly MiB | 7.00 KiB/s
fatal: early EOF
index-pack failed

When I googled the error I was redirected here. And I followed most of the answers but not solved my problem.

The only solution was to re-install my 'Network adapter (WiFi) driver software'. So, what I want to emphasize is the above error can result from the issues in your PC's WiFi driver software, too. If non of the mentioned answers are not working then you can try reinstalling the WiFi driver. It will solve the issue.

You can easily reinstall the WiFi driver as follows:

  1. Open network and internet settings
    Network and internet settings

  2. Select 'Network reset'
    reset network settings

  3. Then select 'Reset now'
    reset network

After rebooting your pc, try git operations successfully (pushing/pulling/cloning).

Pawara Siriwardhane
  • 1,873
  • 10
  • 26
  • 38
2

This may occur after updating your OSX platform.

Open Terminal and navigate to your .ssh-folder, and enter ssh-add -K ~/.ssh/id_rsa

cptstarling
  • 769
  • 6
  • 11
2

PLESK Nginx and GIT I was getting this error on plesk git and while pushing a large repo with (who knows what) it gave me this error with HTTP code 413 and i looked into following Server was Plesk and it had nginx running as well as apache2 so i looked into logs and found the error in nginx logs

Followed this link to allow plesk to rebuild configuration with larger file upload.

I skipped the php part for git

After that git push worked without any errors.

Farrukh Subhani
  • 2,018
  • 1
  • 17
  • 25
2

For us the problem was that we had a ton of files that should have instead been managed by git lfs.

We did the following to resolve the problem:

# Soft reset so you can author a new commit
git reset --soft HEAD~1

# Install git lfs
git lfs install

# Track large files of a specified file type YMMV
git lfs track "*.uasset" "*.umap"

# Re-add everything
git add .

# Author a new commit
git commit -m "git lfs ftw"

# Push
git push
bobbyg603
  • 3,536
  • 2
  • 19
  • 30
1

I happened to have the same error at pull.
I have done the "http.postBuffer" trick. It solved it, but when I wanted to push, I encountered the error again.

What solved my problem:
1. Cloned it to an other folder with an other virtual machine. (Linux).
2. I've done my changes.
3. Pushed it with the original virtual machine where I initially couldn't push. (Windows)

nopara73
  • 502
  • 6
  • 24
  • 3
    I know this is not an ideal solution, but it solved the problem in my case. It can be still lifesaver when all the other answer fails, as they did in my case. – nopara73 Jul 11 '16 at 06:13
1

I have the same problem. I noticed from the git web page that the SSH clone URL have the next structure:

git@github.com:user/project.git

I could resolve my problem just changing the ":" by "/", as follows:

git@github.com/user/project.git

may be this can be helpful.

Jai Chauhan
  • 4,035
  • 3
  • 36
  • 62
1

Seems almost pointless to add an answer, but I was fighting this for ages when I finally discovered it was Visual Studio Online that was suffering a sporadic outage. That became apparent when VS kept prompting for creds and the VSO website sometimes gave a 500.

Counting objects: 138816, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (38049/38049), done.
error: unable to rewind rpc post data - try increasing http.postBuffer
error: RPC failed; curl 56 SSL read: error:00000000:lib(0):func(0):reason(0), errno 10054
The remote end hung up unexpectedly/138816), 33.30 MiB | 3.00 KiB/s
Writing objects: 100% (138816/138816), 50.21 MiB | 3.00 KiB/s, done.
Total 138816 (delta 100197), reused 134574 (delta 96515)
fatal: The remote end hung up unexpectedly
Everything up-to-date

I set my HTTP post buffer back to 2 MB afterwards, since I actually think it works better with many smaller posts.

Asclepius
  • 57,944
  • 17
  • 167
  • 143
Luke Puplett
  • 42,091
  • 47
  • 181
  • 266
1

Seems like it can be one of a thousand things.

For me, I was initially pushing master and develop (master had no changes) via SourceTree. Changing this to develop only worked.

Jake Lee
  • 7,549
  • 8
  • 45
  • 86
1

I was facing a similar error uploading a large repo, "fatal: The remote end hung up unexpectedly" without any further details.

After a lot of research, here's what I did:

  • Using SSH instead of HTTPS, didn't solve the problem.
  • Increasing http.postBuffer incrementally up to a very large value, still no luck.
  • I figured out that it might be because of large files in the repo (as this is a newly migrated repo from perforce), so I recreated the repo using LFS, setting largeFileThreshold to 40m, which greatly reduced the repo size (from 3.5G to 500M). I thought this will solve the problem, but to my surprise I still faced the same error.

Finally, it occurred to me that may be I'm using an older git client, as I didn't see additional error messages. I upgraded git client to latest (2.20.1), and voila, the error is gone!

Mahmoud Hanafy
  • 1,103
  • 12
  • 12
  • I also had this exact issue (migrating from TFS though). I upgraded from 2.19 to 2.20 and it was fixed, a cursory look through release notes didn't reveal what the issue might have been though. – George Richardson Jan 18 '19 at 09:04
  • I have just upgraded to 2.20.1.windows.1 and it still won't let me push to the remote repository – Vidar Feb 06 '19 at 17:43
  • @Vidar May be check for large files, GitHub has a strict limit of 100MB https://help.github.com/articles/what-is-my-disk-quota/; Have a look at "Manually reviewing large files in your repository" section in https://confluence.atlassian.com/bitbucket/reduce-repository-size-321848262.html; the page itself is a good read. – Mahmoud Hanafy Feb 12 '19 at 22:21
  • @MahmoudHanafy - thanks - it was a parameter in the web.config about max file size - increase that and git behaves and everyone is happy! It's not GitHub for me but our own private on site Bonobo.Git.Server. – Vidar Feb 13 '19 at 18:04
1

In my case this error was because of the broken VPN connection. Simply turning off and turning on the VPN fixed the error.

takasoft
  • 1,228
  • 15
  • 15
1

I had the same error message with fatal: The remote end hung up unexpectedly and none of the answers solved my issue. My usual workflow is like this:

  • checkout base branch locally (has a remote origin set up)
  • build child branch from base branch locally
  • do all my coding
  • commit my stuff
  • push it (then console will tell me, that there is no upstream set)
    • setting the upstream by git push --set-upstream origin <remote branch name>

after that my code is usually pushed - but in this case, I had a commit where I touched 110+ files and I got the error.

Solution:

  • renaming the current local branch with git branch -m <branch name temp>
  • checkout base branch (as it best at the same state where the local branch was created)
  • creating the new child branch with the final name with git checkout -b <branch name>
  • pushing the new child branch now without any commit, so that it is created at the remote side (also again by git push --set-upstream origin <remote branch name>)
  • cherrypicking the commits from the <branch name temp> branch
  • pushing the commits (after checking that I cherrypicked all commits in the right order, the first commit needs to be the first cherrypicked one)

and then it worked.

Hope, that helps someone here too! :)

1

Some times when we try to pull from the branch that is not existed in the remote repository then this error will show up.

if the branch exists in the remote repository then try this command:

git config --global http.postBuffer 157286400

Hope this will solve your problem.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
1

I was not able to push the commit on the tip of my branch. I discovered that if I created a few extra commits, I was able to push. The commit that I actually wanted to push was then pushed in the same operation as the subsequent commits. Here is the procedure:

  1. Create new temporary branch: git switch --create temp
  2. Repeat the following until the push is successful:
    1. Make some arbitrary changes
    2. Stage the changes: git add --all
    3. Commit the changes: git commit -m "Temporary commit for tricking git into pushing a previous commit"
    4. Push the changes: git push --set-upstream origin temp
  3. Switch back to your original branch: git switch <branch-name>
  4. Push your branch: git push This should now work, since the commits already exist on remote
  5. Delete the temporary branch locally: git branch -d temp
  6. Delete the temporary branch on remote: git push origin -d temp
Magnar Myrtveit
  • 2,432
  • 3
  • 30
  • 51
  • It would be interesting to know if it also works if the subsequent commits are empty. Then we could simplify the procedure by skipping steps `2.1` and `2.2` and adding `--allow-empty` to step `2.3`. It would be great if someone would test that when running into the issue. – Magnar Myrtveit Jun 20 '23 at 07:49
  • Another thing that would be interesting to test is reverting the commit. Then steps `2.1`, `2.2`, and `2.3` could be replaced by `git revert --no-edit HEAD`. – Magnar Myrtveit Jun 20 '23 at 07:53
1

I got the same issue in my project. When I updated my cocoapods library project file size got increased. After a lot of R&D I got the solution from this question but solution does not worked properly.

My Solutions:-

Step 1. Increase your Buffer size first. buffer size you can increase or decrease according to your requirements.

git config http.postBuffer 2147483648

Or

git config http.postBuffer 524288000

Step 2. Run your command to push code

git push origin yourBranchName

Step 3. Check your git repo at Github or Gitlab updated or not. If it is not updated there use this command to force push to git.

git push origin yourBranchName -f

I hope this would resolve your issue.

Kumar Lav
  • 234
  • 1
  • 3
  • 9
0

I got this error when I had incorrect keypair in .ssh. Adding the pubkey to github (in settings) fixed this issue for me.

Michel Samia
  • 4,273
  • 2
  • 24
  • 24
0

Do this to see the key you're using:

ssh -vT git@github.digitalglobe.com

Then make sure in your build you have this run at the start:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
nik7
  • 806
  • 3
  • 12
  • 20
ddtraveller
  • 1,029
  • 12
  • 18
0

1) cd to the project dir

2) git status

3) git checkout -f HEAD

4) confirm success by pulling down master again to make sure you're up to date if your repo looked incomplete

This works if you get the error in question from Visual Studio's Git when cloning a repo from Bitbucket

whyoz
  • 5,168
  • 47
  • 53
0

This can also happen if any of the commits you're pushing are malformed.

I (unknowingly) had a commit with a malformed Author Email field, but all I was getting was this vague remote end hung up error message. I was able to push other branches just not this one branch, so I started pushing commits from the "bad" branch one at a time until I finally landed at:

Pushing to git@github.com:directangular/unicorn.git
Counting objects: 100% (9/9), done.
Delta compression using up to 20 threads
Writing objects: 100% (5/5), 549 bytes | 549.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0)
remote: error: object 74c7584ff0b93591c19d3a3c19695889dd2274d2: badEmail: invalid author/committer line - bad email        
remote: fatal: fsck error in packed object        
error: remote unpack failed: index-pack abnormal exit
To github.com:directangular/unicorn.git
 ! [remote rejected]       pizzafeast -> pizzafeast (failed)
error: failed to push some refs to 'git@github.com:directangular/unicorn.git'

So it looks like the remote end hung up unexpectedly error is sort of "swallowing" the actual error message, which is probably some kind of malformed commit as I have here.

After fixing the malformed email I was able to push just fine.

mgalgs
  • 15,671
  • 11
  • 61
  • 74
0

I dont think its a good idea to do that but if you have backup in ur machine.. push one more time and then try cloning repo and then remove .git from old dir and move .git from new cloned folder .. git is resolved but because of the issue some files may not upload at git. Push again all from ur back up and then pull it to ur server or the other machine where it get currupted. Right now i just did thid ... Works for me .. and take a backup of your dir before doing this.

And plz correct me if i am wrong. I also dont know what can go wrong after doing this? But this time it really works.

Kouki
  • 37
  • 7
0

my issue (fatal: The remote end hung up unexpectedly) has been resolved by checking repository permission and owner.

git repository files owner must be that user you want push/pull/clone with it.

Samir Sayyad
  • 109
  • 1
  • 6
0

The issue cause for me was network settings : I have a "Killer" wifi card which apparently does muck with network packets in a way that SSH and SSL do not like.

To fix the problem, I had to go into "Killer Control Center", "Parameters", and disable "Advanced Stream Detect" - git commands started working again instantly.

Jean-Michaël Celerier
  • 7,412
  • 3
  • 54
  • 75
0

had same problem and try all answer not work, just try another account and that work for me .

Nozar Safari
  • 505
  • 4
  • 17
0

For me,I got the same error when I tried to pull from a branch which is not even existing.

So kindly check the branch name when you pull.

adi
  • 984
  • 15
  • 33
0

switching from bash shell on vscode to zsh fixed it for me.

Alireza tk
  • 468
  • 1
  • 7
  • 25
0

I got this error too. A second git push did the trick

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 02 '21 at 17:19
0

I tried most of the options above, none did work for me, but this worked

git reset origin/branch_name --force

this will probably work but you will literally lose your work you could copy the changes to git old or new location.

0

Just in case this is useful for others with the same problem, there is an alternate root cause of this issue. By default, I always make shallow clones of repos, usually by specifying a --shallow-since date about 3 months in the past.

If a repo hasn't had any commits in the interval specified by --shallow-since, then git will fail with the same uninformative error message.

The fix is to extend --shallow-since to be far enough in the past that it includes at least one commit from the repo.

Jonathan Mayer
  • 132
  • 1
  • 5
-1

I was able to get around this issue using Git Shell.

Each repository within github.com gives you HTTPS/SSH/Subversion URL's that you can use to download using Shell, see here: http://prntscr.com/8ydguv.
Based on GitHub's recent changes, SSH seems to be the best method.

Command to use in Shell:

git clone "URL of repo goes here w/ no quotes"
David
  • 7
  • 1
-1

I got this error when I had misspelt my remote branch name

javaProgrammer
  • 1,185
  • 1
  • 10
  • 11
-1

for me, I was using git submodules, solved by:

git fetch 

create any commit on the same branch was develop, then.

git push origin develop
git pull origin develop 
Muhammed Moussa
  • 4,589
  • 33
  • 27