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.

  • Clearcase is so slow on checkin: how quickly checkin a large set of modified files?
  • Why does Git display certain new folders when checking out old revisions?
  • How to download the project using the git-svn-id?
  • SVN checkout ignore folder
  • LibGit2Sharp CheckoutPaths()
  • Git fetch/rebase master branch when other branch is checked out
  • 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?

  • Maven release plugin with git, error if commits are pushed during process
  • git pull into a specific directory
  • Git “manual merge” strategy
  • merge strategy in .gitattributes not working
  • How do you pass a file list to the linux zip command
  • Auto update Git Script
  • 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.

    Git Baby is a git and github fan, let's start git clone.