想把檔案include/plugin/funclib/function_member.php
恢復到b257f8685b71a471c4f797d05f52a1a576047ed2
201413882131313f 4713120201313f 685b71a471c4f797d05f52a1a576047ed2 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 <xxx@gmail.com>
Date: Mon Jan 5 22:07:37 2015 +0800
for reset
commit b257f8685b71a471c4f797d05f52a1a576047ed2
Author: ken <xxx@gmail.com>
Date: Mon Dec 29 23:38:09 2014 +0800
add reg forbbiden
commit 052c0233bcaef35bbf6e6ebd43bfd6a648e3d93b
Author: ken <xxx@gmail.com>
Date: Mon Dec 29 21:51:44 2014 +0800
add coname filter for register
commit 53298e00de944863f6092d0d4c0a260d00124f9f
Author: ken <xxx@gmail.com>
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 <xxx@gmail.com>
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)
$
给我你的怀抱2017-04-28 09:08:04
直接用 git-checkout
即可。理解起來稍微有點奇怪就是了。
$ git checkout ${commit} /path/to/file
來源參考:
phpcn_u15822017-04-28 09:08:04
git不能把單獨的某個檔案還原到指定的版本,如果要這要做,可以這樣
1、git reset 版本號,這時候,會產生一個和版本號對應的分支
2.git checkout到這個分支,把要恢復的文件拷貝走
3.git checkout到原來的分支,把文件再拷貝回來,覆蓋掉現在的文件,然後git add,git commit
漂亮男人2017-04-28 09:08:04
1.如果你的提交還沒有分享發佈到遠端可以用git rebase -i origin/branch 來對相應分支進行edit修改後重新提交git commit --ammend。
2,如果你的提交已經分享到遠端只能透過git revert 對應分支的情況,然後將其他文件checkout,只保留這個修改,然後再提交。
3.有點複雜,如果有gui工具就很方便了,我通常是在webstrom的git控制上,點擊某個版本的某個文件右鍵單擊revert再提交即可