Used git checkout to revert a file – anyway to restore it?
I’m picking up work on this Rails system, and was told I could modify the server to do some testing. I made a small change to a few files for testing, confirmed my suspicions, and then did a recursive git checkout on the root directory.
I restarted passenger with no issue, but got an error with MySQL, namely, my database.yml file did not have the right credentials. Turns out that the dev before me had put database.yml in version control, so the usernames/passwords on this system got reverted to the previous commit on the recursive git checkout.
Is there any possible way to get back that version of database.yml? It seems like I want to step forward in my git commits, but I don’t want to monkey around with it if its possible to recover this file. Anyone have any ideas?
One Solution collect form web for “Used git checkout to revert a file – anyway to restore it?”
You should be able to checkout a particular version of a particular file:
git checkout 5ed99fd2 config/database.yml
Use whatever hash (revision) you think fixes the problem. You can switch around pretty quickly until you get it right.
As you’ve observed, putting this into version control leads to nothing but sorrow and pain.