如何将Git LFS文件的旧版本打印到stdout(LFS的git show/git cat文件)? [英] How to print a Git LFS file's old version to stdout (git show / git cat-file for LFS)?

查看:76
本文介绍了如何将Git LFS文件的旧版本打印到stdout(LFS的git show/git cat文件)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该问题的另一个标题可能是如何检出Git-LFS托管文件的多个版本?"

Another title for this question could be 'How to checkout multiple versions of a Git-LFS managed file?'

我想检查Git-LFS中存储的文件的多个版本.因此,我想在我的工作目录中并排使用该文件的多个版本.我想到的是这样的东西:

I would like to inspect several versions of a file stored in Git-LFS. I would therefore like to several versions of this file side-by-side in my working directory. Something like this is what I have in mind:

git show v1:./myfile.ipynb > myfile-v1.ipynb
git show v2:./myfile.ipynb > myfile-v2.ipynb

此操作无法按需工作:该文件由Git-LFS管理,因此要git show每个版本的内容都类似

This does not work as desired: the file is managed by Git-LFS, so to git show its contents at each version looks like

version https://git-lfs.github.com/spec/v1
oid sha256:62aafe00ec8b61a37dd729e7d3a723382...
size 20439

我对文件的"true"(由Git-LFS管理的内容)感兴趣,而不是LFS存储在Git自己的树中的指针文件.

I am interested in the file's 'true', Git-LFS-managed contents, rather than the pointer file that LFS stores in Git's own tree.

如何创建未跟踪的,自定义名称的文件,每个文件都包含由Git-LFS跟踪的文件的特定版本?这不必是单个命令,我已辞职到Git,它需要多步脚本来执行单概念操作.

How can I create untracked, custom-named files that each contain a specific version of a file tracked by Git-LFS? This does not need to be a single command, I am resigned to Git needing multi-step scripts for single-concept actions.

推荐答案

将lfs指针插入git lfs smudge将产生所需的内容.例如:

Piping an lfs pointer into git lfs smudge will yield you what you want. For example:

git cat-file blob <blob-sha> | git lfs smudge

或者,如果您有一个commit-ish(提交哈希,分支名称,仅HEAD等)和一个文件名:

Or if you have a commit-ish (a commit hash, branch name, just HEAD, etc.) and a file name:

git cat-file blob <commit-ish>:path/to/my-large-file.name | git lfs smudge

您可以将输出重定向到文件中.

You could redirect the output into a file.

这篇关于如何将Git LFS文件的旧版本打印到stdout(LFS的git show/git cat文件)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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