Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continue an interrupted git-push (resume upload)

Tags:

git

ssh

So I'm doing this pretty huge git-push, about 2 GB of data being pushed to my server. Suddenly my wifi connection dies. So now after transferring over 250 MB over my slow connection, I have to start again, just to risk the whole thing all over.

[/rant]

When doing a git-push to an SSH remote, is there any way to continue the transfer after it failed?

If not, what's the best way to transfer the repository over a flaky connection, while avoiding to have to upload all of the files?

Thanks!

like image 370
igorw Avatar asked Sep 06 '11 21:09

igorw


People also ask

What happens if git push is interrupted?

The upstream Git repository will be oblivious to your attempted push, and no change will occur upstream. Unfortunately however, as it doesn't do anything with the half-pushed files, it doesn't store it and then expect a continuation of the push later on either.

How to resume interrupted git clone?

No, cloning cannot be resumed, if it's interrupted you'd need to start over. If you suspect that there's a good chance that your clone may be interrupted, look for a git bundle that you can download using a protocol that can be resumed.

Why is git push taking so long?

If you are starting a new project from a clone, (from the CLI without a fork) when you push to a blank remote you are pushing the entire history of the project you just cloned. This is going to take some time. If you just need the clone as it stands and you don't want the history, delete the .


1 Answers

rsync your .git directory of your repo to a new directory, say newdir/.git on your server. Then ssh to that server and do a git checkout on any of the branches you have. Then add the local repo that you wanted to push to originally as a remote and do a local push.

As rsync is immune to network interruption you should be able to continue whenever that happens.

like image 128
holygeek Avatar answered Oct 11 '22 03:10

holygeek