0

There is a commit, pushed etc in the history of our repo. I have the SHA, and I would like to run the equivalent of git revert /one/folder/* THESHAID, but git revert doesn't look like it has the ability to change only a specific folder.

Is there a way to replicate that functionality?

Damon
  • 10,493
  • 16
  • 86
  • 144
  • You can manually edit the patch so that it contains changes in the desired directory only and then revert the patch (patch -R -p1 ) & commit. – brokenfoot Apr 17 '14 at 22:22

1 Answers1

1

This is oddball enough it's no surprise there isn't a pushbutton for it, especially when the brute force method is so easy:

git revert that_commit           # do the whole revert
git reset --hard HEAD^           # in what turns out to have been a throwaway commit
git checkout HEAD@{1} -- one/folder   # and just take what you want of the results
jthill
  • 55,082
  • 5
  • 77
  • 137
  • I just voted to close this as a dup too, @vcsjones's linked answer is conceptually cleaner but clunkier in execution, take your pick. – jthill Apr 18 '14 at 00:03
  • I checked out the other answer.. the logic of these commands makes a lot more sense to me... – Damon Apr 18 '14 at 00:29