git - Is git show safe to use on binary files when the output is redirected to a file?

雨燕双飞 提交于 2019-12-12 16:22:11

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/19369925/git-is-git-show-safe-to-use-on-binary-files-when-the-output-is-redirected-to-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!