39

How I can undo changes made in a specific folder?

I've modified files from multiple folders like

app/code/core/
app/code/local/
app/design/frontend/

I want to undo all the changes made in files present in app/code/core/, while keeping the changes modified in files present in app/code/local/ and app/design/frontend/.

nbro
  • 13,796
  • 25
  • 99
  • 185
amitshree
  • 1,804
  • 2
  • 22
  • 38
  • 1
    You could also stash specific directory if you want... with that trick: http://stackoverflow.com/a/13941132/338581 – noisy Jun 15 '15 at 11:57

2 Answers2

75

If you want to undo the changes, do git checkout app/code/core/

David Deutsch
  • 15,353
  • 4
  • 45
  • 52
-4

For me git checkout -f did the trick, git checkout just lists changes without applying them

Aziris
  • 109
  • 2
  • 8
  • 2
    Be careful with this -- it will undo ALL changes in your entire repo, rather than in a single directory. The reason `git checkout` didn't work for you is that you have to specify a directory with it. For example (for the current directory and all subdirectories): `git checkout .` – Kevin Meboe Jun 17 '21 at 18:53