git 如何还原某个文件
目的
想把文件
include/plugin/funclib/function_member.php
恢复到
b257f8685b71a471c4f797d05f52a1a576047ed2
(2014-12-29 23:38)这个版本,但是使用
git reset b257f8685b71a471c4f797d05f52a1a576047ed2 include/plugin/funclib/function_member.php
一直无法实现。
代码
Administrator@USER-20140115FZ /D/website/xxx.com/www (master)
$ git log include/plugin/funclib/function_member.php
commit bbb0a005d245e6d5ef5b1c0b1b0ef2981fa3ecb9
Author: ken <[email protected]>
Date: Mon Jan 5 22:07:37 2015 +0800
for reset
commit b257f8685b71a471c4f797d05f52a1a576047ed2
Author: ken <[email protected]>
Date: Mon Dec 29 23:38:09 2014 +0800
add reg forbbiden
commit 052c0233bcaef35bbf6e6ebd43bfd6a648e3d93b
Author: ken <[email protected]>
Date: Mon Dec 29 21:51:44 2014 +0800
add coname filter for register
commit 53298e00de944863f6092d0d4c0a260d00124f9f
Author: ken <[email protected]>
Date: Mon Dec 29 01:24:13 2014 +0800
add referrals.php delete some php files like serv.php yqm.php,modify registe
commit 44118e5256eb9786d024f9b7d2dfb8af0bd8a308
Author: default7 <[email protected]>
Date: Sun Jul 27 17:05:21 2014 +0800
first commit
Administrator@USER-20140115FZ /D/website/xxx.com/www (master)
$ git reset b257f8685b71a471c4f797d05f52a1a576047ed2 include/plugin/funclib/fun
ction_member.php --hard
fatal: Cannot do hard reset with paths.
Administrator@USER-20140115FZ /D/website/xxx.com/www (master)
$ git reset b257f8685b71a471c4f797d05f52a1a576047ed2 include/plugin/funclib/fun
ction_member.php
Unstaged changes after reset:
M include/plugin/funclib/function_member.php
Administrator@USER-20140115FZ /D/website/xxx.com/www (master)
$
此ID不存在
11 years, 2 months ago
Answers
直接用
git-checkout
即可。理解起来稍微有点奇怪就是了。
$ git checkout ${commit} /path/to/file
来源参考:
疾风D悠月つ
answered 11 years, 2 months ago