有没有一条命令可以接受引用和文件路径,并输出该提交时文件的完整内容到STDOUT?
例如,像这样的东西:
git show-me-the-file HEAD~2 some/file | do_something_with_piped_output_here
有没有一条命令可以接受引用和文件路径,并输出该提交时文件的完整内容到STDOUT?
例如,像这样的东西:
git show-me-the-file HEAD~2 some/file | do_something_with_piped_output_here
git show
例如:
git show HEAD:./<path_to_file>
git show HEAD -- /<path_to_file>
。你会得到补丁文件语法,我怀疑你不想要。 - Sridhar Sarnobatgit show <ref spec>:<path>
git show 9be20d1bf62:a/b/file.txt
如果您想查看特定分支上的文件:
git show <branch name>:<path>
git show
或 git archive
命令来实现此功能。其中,git show
命令更加适用于将文件输出到标准输出流中。# Show .gitignore from revision before this one.
git show HEAD^:.gitignore
冒号前的部分是根据gitrevisions(7)形成的树状结构,而后半部分是相对于您的git工作树顶部的路径。
git difftool
设置为指向meld。这样,当你需要时,就可以保留一个非GUI的diff工具供git
使用。 - drevicko