在不更改分支的情况下查看不同 Git 分支中的文件 [英] View a file in a different Git branch without changing branches

查看:41
本文介绍了在不更改分支的情况下查看不同 Git 分支中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 git 分支中打开文件而不检查该分支?怎么样?

Is it possible to open a file in a git branch without checking out that branch? How?

本质上,我希望能够在我的 github pages 分支中打开文件,而无需一直切换分支.不想修改,只想看.

Essentially I want to be able to open a file in my github pages branch without switching branches all the time. I don't want to modify it, just want to view it.

推荐答案

这应该有效:

git show branch:file

其中 branch 可以是任何引用(分支、标签、HEAD 等),file 是文件的完整路径.要导出它,您可以使用

Where branch can be any ref (branch, tag, HEAD, ...) and file is the full path of the file. To export it you could use

git show branch:file > exported_file

您还应该查看 VonC 对一些相关问题的回答:

You should also look at VonC's answers to some related questions:

更新 2015-01-19:

UPDATE 2015-01-19:

现在你可以在 git show a1b35:./file.txt 中使用相对路径.

Nowadays you can use relative paths with git show a1b35:./file.txt.

这篇关于在不更改分支的情况下查看不同 Git 分支中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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