How to restore a whole directory from history of git repository?

后端 未结 3 1672
滥情空心
滥情空心 2020-12-07 14:30

I would like to restore a whole directory (recursively) from the history of my git repository.

There is only 1 branch (master).

I know the commit where error

3条回答
  •  清歌不尽
    2020-12-07 14:41

    try adding '--' between revisions and paths:

    git checkout 348ce0aa02d3738e55ac9085080028b548e3d8d3 -- path/to/the/folder/ 
    

    And if you want to recover a directory from the previous commit, you can replace the commit hash by HEAD~1, for example:

    git checkout HEAD~1 -- path/to/the/folder/ 
    

提交回复
热议问题