I am in a developing country and I am trying to continue working on a large project while I'm here. I am currently trying to push about 10 GB of changes through an unreliable 100 kbps connection. I don't know exactly what is going wrong, but I am unable to finish the push, which has ended several times now with this error:
fatal: The remote end hung up unexpectedly
fatal: sha1 file '<stdout>' write error: Broken pipe
A few times in the past I have been able to push my changes using this command:
while ! git push; do sleep 30; done
I usually let that run overnight, and I wake up to see that after a few failures the push went through. But this time, I have been trying for days, and the push just keeps failing with that broken pipe. I think my commit is too big, and it's just not going to work in the couple of hours I have between power outages and internet drops.
Is there a way to push my commit in smaller increments? Or is there a way of starting from where the last broken pipe occurred so that I don't have to start over from the beginning each time?
Git doesn't have any code for resumable pushes.
If your change is made up of multiple commits, you could create a temporary branch containing a few of your commits and push that. Then you could push a new version of that same branch containing a few more commits, and so on. Git knows which objects the remote side has based on which commits are available, so it will avoid sending those objects again.
The way you'd go about this is to do something like the following (assuming you're pushing to origin
):
$ git log # find some early commit; call it COMMIT_ID
$ git push origin COMMIT_ID:temp
and then repeat with some slightly later commit. As long as a commit remains accessible from some branch, Git will know that the remote server has that commit and the objects it depends on.
When you're done, you can push your main branch like normal and use git push origin :temp
to clean up the temporary branch.
If you have only one large commit, you could try creating smaller temporary commits containing the complete changes to only some of those files, pushing those, and then trying again with more changes. That may or may not work, though.