Jim
Jim

Reputation: 521

Retrieving deleted files in git

I have folder of user data which I thought was .gitignored , however I was wrong and when I did a pull I got a conflict.

Currently, if I type "git status" I get a list of the files ( eg. "deleted: projects/tom/demo_project/1_2.mp3"), but they have actually been deleted.

Is it possible to recover this data?

Upvotes: 1

Views: 818

Answers (2)

jthill
jthill

Reputation: 60235

If the cuckoos might not have been added recently,

git log -a --oneline -- \*/cuckoos/glob/*

will show the commits that added or changed them, and

git log -a --source --decorate --ancestry-path --oneline --graph ^the-1st-of-them

will show everything that's been tainted -- with any luck, a short list all on your current branch. If so, the reset will do you fine. Otherwise you're headed for filter-branch territory.

Unless you've gone in and explicitly told git to get all draconian on your ass, git will forget nothing it has seen in the last 90 days, even things you added and then abandoned without ever committing. You can reproduce and play mix-n-match with anything git has seen.

Upvotes: 0

larsks
larsks

Reputation: 311238

Assuming everything had previously been added to your local repository, you can use the git reset --hard command to restore your local repository to its state before your git pull command.

This page has more information than you'll ever want about the reset command.

Upvotes: 2

Related Questions