问题
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
回答1:
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 beforemaster
)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.
回答2:
rsync your .git/objects directory to the remote, then do git push - it will go much faster.
来源:https://stackoverflow.com/questions/7757164/resuming-git-push