git - 当输出重定向到文件时,git show可以安全地用于二进制文件吗? [英] git - Is git show safe to use on binary files when the output is redirected to a file?

查看:463
本文介绍了git - 当输出重定向到文件时,git show可以安全地用于二进制文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到可以从Git中的特定版本检索单个文件,就像在这个SO问题中回答的那样:

如何从Git中的特定修订中检索单个文件?

所以我想知道用二进制文件做这件事是否安全。我有一些正在使用的二进制文件,我不想检查它们,我真正想做的是将它们从特定修订版本中复制出来。我试过这个:

  git show HEAD〜1:database.db>数据库副本从mmddyy.db 

这似乎工作,因为在输出中该提交的database.db完全匹配。但我不知道这是允许使用 git show ?它支持我在做什么,并且结果始终是正确的并且不会损坏(例如,autocrlf翻译,例如..我在Windows msysgit中)。谢谢!

解决方案

是的,完全安全。从> git help show


对于普通blob,它显示普通内容[...],blob对象的内容未被解释字节序列。在核心级没有编码翻译

测试说同样的事情:没有应用属性。 / p>

I read that it's possible to retrieve a single file from a specific revision in Git, as answered in this SO question:
How to retrieve a single file from specific revision in Git?

So I want to know if it's safe to do that with binary files. I have some binary files in use and I don't want to check them out, really what I want to do is copy them out from a specific revision. I tried this:

git show HEAD~1:database.db > copy-of-database-from-mmddyy.db

That seems to work, as in the output is an exact match of database.db for that commit. But I have to wonder is this an allowed use of git show? Does it support what I'm doing and will the result always be correct and not corrupt (ie autocrlf translation for example.. I'm in Windows msysgit). Thanks!

解决方案

Yep, perfectly safe. From git help show:

For plain blobs, it shows the plain contents[ ... t]he contents of the blob objects are uninterpreted sequences of bytes. There is no encoding translation at the core level.

And testing says the same thing: no attributes are applied.

这篇关于git - 当输出重定向到文件时,git show可以安全地用于二进制文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆