更新时间:2023-01-17 18:23:38
您知道该文件属于哪个提交(即:特定修订版)?然后执行:
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).