Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
519 views
in Technique[技术] by (71.8m points)

git - 是否有快速的Git命令来查看文件的旧版本?(Is there a quick Git command to see an old version of a file?)

Git中是否有命令可以查看(转储到stdout或$PAGER$EDITOR )特定文件的特定版本?

  ask by mike translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use git show with a path from the root of the repository ( ./ or ../ for relative pathing):

(您可以将git show与来自存储库根目录的路径一起使用( ./../用于相对路径):)

$ git show REVISION:path/to/file

Replace REVISION with your actual revision (could be a Git commit SHA, a tag name, a branch name, a relative commit name, or any other way of identifying a commit in Git)

(将REVISION替换为您的实际修订版(可以是Git提交SHA,标签名称,分支名称,相对提交名称,或在Git中标识提交的任何其他方式))

For example, to view the version of file repository-root/src/main.c from 4 commits ago, use:

(例如,要从4次提交之前查看文件repository-root/src/main.c的版本,请使用:)

$ git show HEAD~4:src/main.c

Git for Windows requires forward slashes even in paths relative to the current directory.

(Git for Windows即使在相对于当前目录的路径中也需要正斜杠。)

For more information, check out the man page for git-show .

(有关更多信息,请查看git-show的手册页。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...