In a git repository I have a subdirectory that I want to reset to a specific state in the past (an earlier commit). Is it possible to undo all commits on files in a specific subdirectory? I think there are no commits that apply changes to files within this subdirectory and on files located elsewhere at the same time. But it would be nice if it were possible to leave commits on files unaffected that are not located in this directory?
I don’t need to remove the history. It would be no problem to checkout the old state, remove the current content of the subdirectory, and copy and commit the old state in its place. But eventually there may be a more elegant (gitonic) way.
The simplest way to do it to use the ability of
git checkoutto be applied on a subdirectory. Then stage and commit: