想把文件 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 <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)
$
Just use
git-checkout
directly. It's just a little strange to understand.Source reference:
Still needs to be executed
git checkout xxxxx(文件名)
Git cannot restore a single file to a specified version. If you want to do this, you can do this
1. git reset version number. At this time, a branch corresponding to the version number will be generated
2. git checkout to this branch and copy the files to be restored
3. git checkout to the original branch, copy the file back, overwrite the current file, then git add, git commit
I think it’s good to use tortoisegit. After configuration, there is a graphical interface directly, and you can use rever to restore the previous version
1. If your submission has not been shared and published to the remote end, you can use git rebase -i origin/branch to edit the corresponding branch and then resubmit git commit --ammend.
2. If your submission has been shared to the remote end, you can only use git revert to the corresponding branch, then checkout other files, keep only this modification, and then submit.
3. It’s a bit complicated. It would be very convenient if there is a gui tool. I usually click on a file of a certain version in the git control of webstrom, right-click revert and then submit it
git checkout <sha1-of-a-commit> </path/to/your/file>