Lloyd Crawley
Lloyd Crawley

Reputation: 616

When Git deletes or removes a file where does it go?

When Git removes files either through a soft or hard reset - where do these files go? Is there any way to go back to the condition before a mixed reset?

Normally when a file is deleted on an operating system, it goes to a trash can. When files are deleted or removed via Git they seem to go into an ether. Where do these files go?

I have a stack of new files that weren't added properly and I foolishly ran a mixed reset and now these files are no where to be seen.

I'm using SourceTree for OS X by the way.

Upvotes: 0

Views: 315

Answers (2)

mockinterface
mockinterface

Reputation: 14880

When files are deleted or removed via Git they seem to go into an ether. Where do these files go?

When you do a hard reset git will unlink(2) the files.

The data might still be there on the file system but there are no guarantees. Please read https://unix.stackexchange.com/questions/10883 where some recovery tools are mentioned, mostly for ext3.

The git commit, stash and branch commands are often used to save work. Also pay a special attention to the reflog for locating and re-retrieveing runaway leaf changes, especially after a reset.

Upvotes: 1

infused
infused

Reputation: 24337

If you did a --mixed or --soft reset , then the files in your directory would not have gone anywhere because those types of resets do not effect your working tree. With a --hard reset the files in your working tree will be deleted.

Upvotes: 2

Related Questions