Search code examples
gitgit-revert

git: revert all committed files in a directory to master


I have a feature branch feature-1-branch created from master. A lot of time as passed and I created a lot of commits on feature-1-branch.

Now I want to revert commit all changes in a specific directory, lets say src/modules/feature-2 I made in branch feature-1-branch back to the state as they are in master.

Im sure this must be possible in git, just not sure how to do it!?


Solution

  • Just checkout src/modules/feature-2 directory from feature-1 branch to origin/master branch.

    $ git checkout feature-1-branch
    $ git fetch
    $ git checkout origin/master src/modules/feature-2/
    

    Now, You have identical src/modules/feature-2 directory in both master and feature-1-branch branch.