简体   繁体   中英

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.

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM