简体   繁体   English

如何使用 git 从另一个分支打印文件?

[英]How do I print a file from another branch with git?

I know there's git cat-file but it takes a sha我知道有git cat-file但它需要一个sha

what I want to do is something like git cat-file mybranch -- path/to/myfile.txt which would accomplish the same thing as我想做的是git cat-file mybranch -- path/to/myfile.txt之类的东西,它可以完成与

git checkout mybranch && cat path/to/myfile.txt

except it wouldn't actually checkout the branch.除非它实际上不会结帐分支。 How can I do this?我怎样才能做到这一点?

You can do it in many ways:您可以通过多种方式做到这一点:

git cat-file blob mybranch:path/to/myfile.txt

or或者

git show mybranch:path/to/myfile.txt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将单个文件的版本从一个 Git 分支复制到另一个? - How do I copy a version of a single file from one Git branch to another? 如何在git中将文件历史记录从一个分支合并到另一个分支? - How can I merge a file history from a branch to another in git? 如果我从另一个分支推送,是否会在 git 分支上提交? - Will a commit on a git branch follow if I do a push from another branch? 使用 git,我如何忽略一个分支中的文件但将其提交到另一个分支? - Using git, how do I ignore a file in one branch but have it committed in another branch? 如何使用git将另一个分支中的文件签出到当前分支的新文件中? - How can I check out a file from another branch into a new file in the current branch with git? 如何获得另一个git分支到当前分支? - How do I get another git branch up to current branch? GIT:如何从一个分支还原一个分支的所有更改 - GIT: How Do I Revert All The Changes Of One Branch From Another Branch 当存在不共享的文件时,如何从另一个分支更新 git 分支? - How can I update a git branch from another branch when there are files that do not share? 如何将所有文件和文件夹从一个分支替换/复制到GIT中的另一个现有分支 - How Can I replace/copy all file and folder from one branch to another existing branch in GIT 如何将一个分支中的特定文件合并到Git中的另一个分支中 - How can I merge a specific file from one branch into another branch in Git
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM