在不改变分支的情况下在不同的Git分支中查看文件 [英] View a file in a different Git branch without changing branches
问题描述
是否有可能在没有检出分支的情况下在git分支中打开文件?如何?
基本上,我希望能够在我的 github页面分支,而无需切换分支。我不想修改它,只是想查看它。
这应该工作:
git show分支:文件
<其中分支可以是任何ref(分支,标签,HEAD,...)和文件是文件的完整路径。要导出它,你可以使用
git show branch:file> exported_file
您还应该看看 VonC 对一些相关问题的回答:
UPDATE 2015-01-19:
现在你可以使用相对路径和 git show a1b35:./ file.txt
。
Is it possible to open a file in a git branch without checking out that branch? How?
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.
This should work:
git show branch: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
You should also look at VonC's answers to some related questions:
- How to retrieve a single file from specific revision in Git?
- How to get just one file from another branch
UPDATE 2015-01-19:
Nowadays you can use relative paths with git show a1b35:./file.txt
.
这篇关于在不改变分支的情况下在不同的Git分支中查看文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!