从git中的旧提交恢复文件 [英] Restore file from old commit in git

查看:100
本文介绍了从git中的旧提交恢复文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个星期前做过的一个老承诺。我想从该提交中只恢复一个文件。

- path / to / file.txt

这不会改变HEAD,只会覆盖本地文件 path / to / file.txt



请参阅 man git-rev-parse ,以获得可能的修订规范(当然还有一个简单的哈希(如 dd9bacb )会很好地完成)



不要忘记提交更改(在审核完成后...)


I have an old commit that I did a few weeks ago. I want to restore only a single file from that commit. What do I do?

解决方案

git checkout 'master@{7 days ago}' -- path/to/file.txt

This will not alter HEAD, it will just overwrite the local file path/to/file.txt

See man git-rev-parse for possible revision specifications there (of course a simple hash (like dd9bacb) will do nicely)

Don't forget to commit the change (after a review...)

这篇关于从git中的旧提交恢复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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