chris P
chris P

Reputation: 6589

Git: If I delete a local file, and commit it, will it also remove the file from my repository?

I 99% assume not, otherwise what's the point of source control, but I've just deleted nearly 100 files that I may want down the road. I'm about to commit these deletions via

git add .
git commit -m "blah"
git push

but I just want assurance that these will not be removed from my repository, and that I can always claim these files down the road if I want to.

Upvotes: 2

Views: 38

Answers (2)

trent
trent

Reputation: 27895

Assuming that they were committed before, they cannot be un-committed; they'll always exist in the repo's history. You can get back an old version of a file (even a deleted file) by, for instance:

$ git checkout e9cfa89 -- deleted.dat    (e9cfa89 being a commit)
$ git checkout v0.9 -- deleted.dat       (v0.9 being a tag)

Upvotes: 3

David Deutsch
David Deutsch

Reputation: 19025

No, they will still be in your history. Note that to commit the deletions, you need to do git add --all.

Upvotes: 2

Related Questions