如何在Git中检出一个特定版本的文件? [英] How can I check out a particular version of one file in Git?

查看:194
本文介绍了如何在Git中检出一个特定版本的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我发现

如何在git中查看某个文件的特定版本? / 2009/1/6/4608324 / thread + git + checkout + a + file& cd = 6& hl = zh-CN& ct = clnk& gl = usrel =noreferrer>邮件列表上的这封邮件,其中说:

$ $ $ $ g $ check $ $ git checkout HEAD〜43 Makefile
$ git reset Makefile
code>

但是我不明白如何找出'HEAD〜43',如果我做一个 git log aFile ,我怎么才能知道我应该用哪个'HEAD〜43'?



为什么我需要运行 git reset 为那个文件?它是干什么的?

解决方案

您知道该文件属于哪个提交(即:特定修订版)?然后执行:

  git checkout< commit> <文件> 

其他命令:

  git checkout HEAD〜N< file> 

适用于你希望从某个范围获得文件版本怀旧)。


How can I check out a particular version of one file in git?

I found this mail on the mailing list, which said:

$ git checkout HEAD~43 Makefile
$ git reset Makefile

But I don't understand how to find out 'HEAD~43', if I do a git log aFile, how can I find out which 'HEAD~43' I should use?

And why do I need to run git reset for that file? What does it do?

解决方案

You know what commit (ie: the specific revision) the file belongs to? Then do:

git checkout <commit> <file>

The other command:

git checkout HEAD~N <file>

Is for when you want to get a version of the file from a range back (which I do for nostalgia).

这篇关于如何在Git中检出一个特定版本的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆