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?

1 Answer 1

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.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.