问题描述
我使用的连接确实不可靠,虽然我尝试暂存提交,所以它们都不超过20mb,并且/或者一旦它们达到这样的大小就将它们推送,有时是不可能的(一些资产可以变得很大-我也知道对资产使用git也不是最好的主意),并且在发送所有内容之前,我的连接有90%的机会会失败.
I'm using a really unreliable connection and while I try to stage commits so none of them is over 20mb and/or to push them once they reach a size like that, sometimes it's not possible (a few of the assets can be big - I know it's not the best idea to use git for assets too) and there are 90% of chances my connection will fail before everything is sent.
是否可以一一推送提交,或者您是否可以建议其他对这种情况有用的技巧?
Is it possible to push commits one by one, or can you suggest any other tips that could be useful for this case?
推荐答案
是的,不仅是可能的,而且实际上是微不足道的.代替:
Yes, it's not only possible but in fact pretty trivial. Instead of:
git push remote branch
只需运行:
git push remote <commit-hash>:branch
每一次提交尝试以适当的顺序(从父级到子级)进行推送.
once for each commit to try pushing, in the appropriate (parent-most to child-most) order.
要自动执行此操作,假设您的遥控器命名为 origin
,而您的分支命名为 branch
,而您的 origin/branch
远程跟踪分支为最新(如果没有,请运行 git fetch origin
):
To automate this, assuming your remote is named origin
and your branch is named branch
and your origin/branch
remote-tracking branch is up to date (run git fetch origin
if not):
for rev in $(git rev-list --reverse origin/branch..branch); do
git push origin $rev:branch;
done
这实际上是一个单行,分为三行,用于StackOverflow发布.(请注意:这也假定了或多或少的线性历史记录;如果没有,则添加-topo-order
以保证内容,但是随后您需要-force
这里有各种各样的坏主意,所以这不是走的路:您想拆分推送以使用临时分支,或者在合并点处汇总它们.)
which is really a one-liner split into three lines for StackOverflow posting purposes. (Note: this also assumes a more or less linear history; add --topo-order
to guarantee things if not, but then you'll need --force
and there are various bad ideas occurring here, so that's not the way to go: you'd want to split the pushes to use a temporary branch, or aggregate them at the merge points, perhaps.)
这篇关于有可能在git中一次而不是一次全部推送提交吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!