7

I removed a file in my local Git repo. I want the file back by updating my Git repo.

I run the following unsuccessfully

git pull

It says upToDate, but I did not get the newest file. The public repo at github does not use SVN, so the problem cannot be SVN.

How can you update your local Git repo, such that you get your removed File back to your computer?

Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697

2 Answers2

8

If it hasn't been committed yet:

 git checkout path/to/file
August Lilleaas
  • 54,010
  • 13
  • 102
  • 111
  • @SimpleQuestions: The path should be a relative path to the file in your local repository, e.g. "git checkout theFile". You may also specify the revision "git checkout master~1 theFile". See the examples at http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html – Esko Luontola May 09 '09 at 09:08
7

August has the probably best way for your problem.

You could also revert to the last version you pulled:

git reset --hard
Lennart Koopmann
  • 20,313
  • 4
  • 26
  • 33