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

后端 未结 3 1663
滥情空心
滥情空心 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:56

    There are two easy ways to do this:

    If the commit that included the errors only included the errors, use git revert to invert the effects of it.

    If not, the easy path is this:

    1. git checkout 348…
    2. cp -a path/to/the/folder ../tmp-restore-folder
    3. git checkout HEAD # or whatever
    4. rm -rf path/to/the/folder
    5. mv ../tmp-restore-folder path/to/the/folder
    6. git add path/to/the/folder
    7. git commit -m "revert …"

提交回复
热议问题