9

I am trying to recover a file that was accidentally removed when I merged a branch to the master.

Now, when I try to do a git checkout of a new branch I get this message:

 $ git checkout testingNewFormStyle
D       module/FormDependencies/src/FormDependencies/Entity/LanguageList.php
Switched to branch 'testingNewFormStyle'

However, I want to restore that file. How can I do this?

khant vyas
  • 123
  • 3
andreea115
  • 289
  • 1
  • 3
  • 14

1 Answers1

25

You can do, for instance:

git checkout HEAD -- module/FormDependencies/src/FormDependencies/Entity/LanguageList.php

This will checkout the file as it exists in the HEAD refspec (ie, the current branch). If HEAD is not what you want, replace with the appropriate refspec.

fge
  • 119,121
  • 33
  • 254
  • 329