[英]How can I check out a file from another branch into a new file in the current branch with git?
Let's say that I have a file core.clj in branch master at HEAD which is distinct from core.clj in branch other at HEAD, and that I am currently in branch other. 假设我在HEAD的分支主机中有一个文件core.clj,它与HEAD中的分支机构中的core.clj不同,而且我目前在分支机构中。 I would like to checkout master's core.clj into the current branch with some other file name, say tmp.clj, for easy comparison.
我想将master的core.clj用一些其他文件名(例如tmp.clj)检入当前分支,以便于比较。
How can I do this? 我怎样才能做到这一点?
You can use git show master:core.clj
to show the file. 您可以使用
git show master:core.clj
来显示该文件。 Redirect it to a new file ( git show ... > temp.clj
to save it for further processing. 将其重定向到一个新文件(
git show ... > temp.clj
以保存它以供进一步处理。
You don't need to; 你不需要;
git diff
will do exactly what you need to do. git diff
将完全按照您的需要做。 git diff master otherbranch core.clj
is a basic use of the command, and if you need more help, man git-diff
can explain more to you. git diff master otherbranch core.clj
是命令的基本用法,如果你需要更多的帮助, man git-diff
可以向你解释更多。
这非常简单:
git checkout master -- core.clj
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.