top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to recover deleted files from a bad usage of .gitignore

+3 votes
504 views

Does someone know where the files after a "git rm" go? Some of my files where deleted by git, of course I have no copy, I tried several file recovery utilities, but so far none of them see the deleting files.

I am running Windows 7; git 1.9.4; gitextension 2.48.03

Full story:
One week ago I created a new repository from an old CVS server. I checked it out from scratch (clone it), into CLONE, and copy the .git folder into a folder, MyFolder, containing some changes that were not pushed under CVS. So far everything ran fine, I could pushed the new changes.

However, MyFolder contained also a a folder called Perso with some files I did not want to push. Therefore I added Perso/* into .gitignore. Then the folder Perso disappeared as potential commit. So far so good. Then I don't really remember what I've done, maybe clean some branches? but yesterday I remarked that Perso/ was no more on the disk.

Currently there is no stash, no other branches. I tried a menu (under GitExtensions) "Repository/Git Maintenance/Recover lost objects" with option "print out objects that exists but that aren't readable from any of the reference nodes"... without success. I suppose git removed my files when switching the branch? Hence my question, is there a change I could get these files back? I am afraid they are lost... what a silly situation.

posted Feb 10, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Hi, when you ignore a file in git it becomes invisible to git, so you cant use git to try to recover it after a deletion.

About your question about git rm AFAIK it deletes the file and marks it to the stage area. Anyway if you use git rm it means that you have the file under git, so you can use git to recover it.

I remember, using git for Windows that some untraked files where deleted, luckily it didn't make any damage in my repo. I think you need to keep trying with file recovery utilities.

answer Feb 11, 2015 by Ramakrishnan
Similar Questions
+1 vote

I wanted to avoid push if any of the files is deleted from the local git clone area. Can anyone please help me with that?

I am using Stash for repository management.

+1 vote

I was trying to program with txt files, and tried to move the txt file to a new directory. By mistake I have deleted some of my files. How do I recover my lost files using python or any other method?

0 votes

.gitignore is a flexible way to customize what dir/file to search or not to search. So it is of general use and is more flexible than what is offered by "find". I'm wondering if there is an API than I can use besides using it within git.

...