且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在不更改分支的情况下查看不同 Git 分支中的文件

更新时间:2022-05-12 02:06:09

这应该有效:

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.