git squash 后跟 Push 重新传输数据
我想将一个充满二进制数据的目录 git-push 到远程服务器。
由于这可能需要几天的时间,我在本地提交并一次推送一个文件(如果我一次提交所有内容并推送,如果传输中断,则必须从头开始,对吗?)。
当所有内容都转移后,我想将所有这些提交压缩为一个。如果我在本地压扁然后推送,所有数据都会再次传输!这违背了我的策略的目的。
也许我可以登录远程,并远程重复挤压操作,但是有没有更好的方法来做我想做的事情。如何通知 git 所有敏感数据已经在服务器上?
I want to git-push a directory full of binary data to a remote server.
As this may take days, I commit locally and push one file at a time (if I commit everything at once and push, if the transfer is interrupted, it has to be restarted from the beginning, right?).
When everything is transferred, I want to squash all these commits into one. If I squash locally and then push, all the data is being transmitted again! which defeats the purpose of my strategy.
Maybe I could log into the remote, and repeat the squash operation remotely, but is there a better way of doing what I want to do. How to inform git that all the sensible data is already on the server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,二进制文件在 VCS 中的管理不是最好的;)
其次,如果必须的话,您可以在远程存储库上设置一个钩子,以便在收到某个提交时执行压缩(就像只包含一个特殊文件的推送,验证所有内容)之前的提交可以被压缩)。
我不确定确切的实现,但似乎任何涉及 git 挤压的解决方案都必须在本地和远程端进行,以确保类似的历史记录。
如果其他贡献者对所述远程存储库进行其他提交,那将非常安全。那么历史记录将不可能在本地存储库和远程端所做的事情之间正确同步......
在进行这种特殊的推送并在远程端进行挤压之后,唯一的其他操作是重命名当前分支,并拉取远程分支,以便将所述分支的本地版本重置为远程端的版本。
First, binaries are not best managed in a VCS ;)
Second, if you must, you could setup a hook on the remote repo to perform the squash when receiving a certain commit (like a push containing nothing but a special file, validating that all the previous commits can be squashed).
I am not sure about the exact implementation, but it seems any solution involving a git squash would have to take place both locally and on the remote side, to ensure similar history.
And that would be very safe if there are other commits from other contributors to said remote repository. Then the history would be impossible to synchronize correctly between your local repo and what would have been done on the remote side...
The only other course of action after such a special push followed by a squash on the remote side would be to rename your current branch, and to pull the remote branch in order to reset the local version of said branch to what is on the remote side.
我不确定,但我认为如果 git 已经拥有这些对象,它就不会传输这些对象。从技术上讲,提交不包含二进制对象,而仅包含对包含对象引用的树的引用。每个对象都有一个唯一的 ID(SHA),因此它应该知道它是否已经拥有它们。所以通常不需要第二次发送二进制对象。
只要尝试一下,就可以按您想要的方式工作,而无需执行任何操作。
I'm not sure but I think git won't transmit the objects if it have them already. Technically the commit doesn't contains your binary objects but only a referece to a tree which contains references to objects. Each object as an unique id (the SHA) so it should know that it had already them or not. So normally there is no need to send a second time the binary objects.
Just try it, and that should work as you want without doing anything.