How do I pull missing file back into my branch

feronovak picture feronovak · Mar 14, 2012 · Viewed 76.6k times · Source

I have cloned git project into local git repository. Then I have done something nasty to one of the files and in that panic I deleted file physically from drive (rm style.css) and also removed it from git (git rm style.css).

I want to get original style.css back from origin to my dev branch. Unfortunately my git thinks it is up-to-date and wont do anything.

root@debian:~/project.me# git status
# On branch dev
nothing to commit (working directory clean)

root@debian:~/project.me# git pull origin dev
Password for 'https://[email protected]':
From https://github.com/somewhere/project.me
* branch            dev        -> FETCH_HEAD
Already up-to-date.

What do I need to do to tell git that I want to download original style.css file back into my dev branch?

Answer

CJlano picture CJlano · Mar 14, 2012

Use git checkout. In your case:

git checkout origin/master style.css

This command will update the requested file from the given branch (here the remote branch origin/master).

Hope this helps