12

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!

knocte
  • 16,941
  • 11
  • 79
  • 125
igorw
  • 27,759
  • 5
  • 78
  • 90
  • I'm pretty sure that the server end will clean up any incomplete object transfers when the connection is closed, but I'm not 100% sure. – cdhowie Sep 06 '11 at 21:20
  • I would think if it is interrupted, you have to do it from scratch again. – manojlds Sep 06 '11 at 21:40

1 Answers1

3

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.

holygeek
  • 15,653
  • 1
  • 40
  • 50
  • You can copy the existing .git directory on the server to the newdir/.git directory before starting rsync but that might not save you much in term of data that will need to be transferred because of the way git creates packfiles. – holygeek Sep 06 '11 at 22:34
  • Good idea, but I guess this could be inefficient if the repo is even larger than the push to be done. – a3nm Sep 06 '11 at 22:35
  • 1
    make sure to use rsync -P though, to allow partial transfers. – user1001630 Jan 28 '14 at 07:53