我想从我的git存储库的历史中恢复整个目录(递归).
只有一个分支(主).
我知道包含错误的提交.
我可以使用父提交的sha1哈希来恢复目录的状态,因为它是在包含错误之前的状态吗?
我想过这样的事情:
git checkout 348ce0aa02d3738e55ac9085080028b548e3d8d3 path/to/the/folder/
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
Car*_*rós 139
尝试在修订版和路径之间添加" - ":
git checkout 348ce0aa02d3738e55ac9085080028b548e3d8d3 -- path/to/the/folder/
Run Code Online (Sandbox Code Playgroud)
upt*_*you 10
对于现代 git (-s或--source):
git restore -s commit-sha-that-contains-dir relative/path/to/folder
Run Code Online (Sandbox Code Playgroud)
男人参考:
-s <tree>, --source=<tree>
Restore the working tree files with the content from the given tree. It is common to specify
the source tree by naming a commit, branch or tag associated with it.
If not specified, the contents are restored from HEAD if --staged is given, otherwise from the index.
As a special case, you may use "A...B" as a shortcut for the merge base of A and B if there
is exactly one merge base. You can leave out at most one of A and B, in which case it
defaults to HEAD.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
47682 次 |
| 最近记录: |