How to revert specific files/folders

49 views Asked by At

Let's say I have a git repo and inside there are various sub projects. How can one revert back changes in one sub project without affecting all the other sub projects to the state they were in of the commit you want to revert to? So for one sub project I revert back to older commit, while the rest of the sub projects stay at the current version?

1

There are 1 answers

0
David Deutsch On BEST ANSWER

Assuming you want to revert the changes to the subproject made in commit C, I would do the following:

git revert C --no-commit                     #staging area contains all reverted files
git reset                                    #working directory contains all reverted files
git add /path/to/subproject                  #staging area contains reverted subproject
git commit
git reset --hard                             #working directory now reflects repository