恢复 git 推送

发布于 2024-12-09 19:52:18 字数 185 浏览 6 评论 0原文

我正在尝试对一个大项目进行 git 推送到远程服务器。 有没有什么办法,一旦上传开始,如果连接丢失,我可以恢复 git Push 命令,而不必重新开始?

编辑:我正在尝试推送到 github

edit2:所以看来要采取的方法是增量进行。有人可以举例说明当我的计算机上已有完整存储库时如何执行此操作吗?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

┈┾☆殇 2024-12-16 19:52:18

Hacky 解决方法:推送几个中间提交,这样你就不会每次都推送那么多。如果这是一个未能推动的巨大提交,这当然不会拯救你。

# 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

有两种主要方法可以选择要推送的提交:

  • master~15master~10master~5(15、 10 次,以及 master 之前的 5 次提交)

  • 使用gitk手动查找它们;当你在历史记录中选择一个提交时,SHA1会自动放入中键粘贴剪贴板中。

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.

梦初启 2024-12-16 19:52:18

rsync 你的 .git/objects 目录到远程,然后执行 git push - 它会快得多。

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

盗琴音 2024-12-16 19:52:18

增量 git 推送

r=remote
b=main # branch
n=$(git rev-list --count --first-parent $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

incremental git push

r=remote
b=main # branch
n=$(git rev-list --count --first-parent $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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文