8

I am trying to do a git push to a remote server, for a big project. Is there any way once the upload is started, that if the connection is lost, I can resume the git push command and not have to start all over again?

edit: I am trying to push to github

edit2: so it seems that the way to go is doing it incremental. Can somebody put an example on how to do that when I have the full repository already on my computer?

Thanks

Daniel Benedykt
  • 6,496
  • 12
  • 51
  • 73
  • 1
    I wouldn't be surprised if this were automatic; although you could have better results with git-send-pack directly – sehe Oct 13 '11 at 16:22
  • Duplicate of http://stackoverflow.com/questions/7326290/continue-an-interrupted-git-push-ssh ? – Roberto Aloi Oct 13 '11 at 21:43
  • Thanks Roberto, but I am trying to push to github so I dont think rsync is possible – Daniel Benedykt Oct 14 '11 at 00:36
  • If this is a recurring problem, as a hacky workaround, you could try pushing incrementally instead - move your branch up a few commits, push, a few more, push... – Cascabel Oct 14 '11 at 00:41
  • Thanks Jefromi, can you please put your answer with an example? Thanks – Daniel Benedykt Oct 14 '11 at 11:59
  • Incremental pushes aren't necessarily the way to go. What's causing the failures? If you have enormous commits, you might want to solve that problem instead. – Cascabel Oct 21 '11 at 03:44

3 Answers3

9

Hacky workaround: push several intermediate commits, so that you're not pushing as much each time. This of course won't save you if it's a single enormous commit that's failing to push.

# develop, and end up wanting to push master
git branch master-tmp <commit>
git push origin master-tmp:master
git branch -f master-tmp <a more recent commit>
git push origin master-tmp:master
# ...keep going until you've pushed everything you want

There are two primary ways to pick the commits to push:

  • master~15, master~10, master~5 (15, 10, and 5 commits before master)

  • Use gitk to manually find them; when you select a commit in the history, the SHA1 is automatically put in the middle-click paste clipboard.

Cascabel
  • 479,068
  • 72
  • 370
  • 318
2

incremental git push

r=remote
b=main # branch
n=$(git rev-list --count $b) # total number of commits
d=1000 # delta. push $d commits per iteration
for i in $(seq $n -$d 0 | tail -n +2)
do
  (set -x; git push $r $b~$i:$b)
done &&
git push $r $b:$b
milahu
  • 2,447
  • 1
  • 18
  • 25
2

rsync your .git/objects directory to the remote, then do git push - it will go much faster.

Ana Betts
  • 73,868
  • 16
  • 141
  • 209