Marty Marty -4 years ago 150
Git Question

Why doesn't git pull bring back directories that I've deleted?

I've just started learning how to use

git
today, progressing well.

As an experiment, I used
push
to upload two directories (containing two files each) and two files in the root directory. This worked fine.

I then deleted one of the two directories that I have locally (but not on git). When I use
git status
it seems to be aware of this:


deleted: test/Testfile.as


deleted: test/Testile2.as



But when I use
git pull
to get my files back, they don't seem to return to my local folder. I've also tried
git fetch
.

The only way I seem to be able to get everything back is
git clone
, but that doesn't seem logical as I need to delete my master directory locally and then clone it back again (or alternatively specify a new location for the cloned files).

What is the appropriate way to retrieve files and folders from github that have been deleted locally?

Answer Source

git pull just merges the fetched commits in your working directory and will not restore your deleted directory ( but might warn you about conflicts.)

If you have deleted the folders in your working directory, you have to do:

git checkout -- test

to get it back.

Or you can do git reset --hard to completely bring your working directory to HEAD state.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download