Deletion of file in .git folder

I have unintentionally deleted a file in the .git folder. The repository seems to still work (commit, push, pull, … are working without problems). Could a deletion of a file inside the .git folder affect the files outside this folder? could the deletion undo some changes in the repository files?

That really depends on exactly which file it was. Some are harmless, because they are optional, or caches that git will recreate when needed (e.g. .git/COMMIT_EDITMSG). Deleting certain other files will break your repository, or at least certain aspects of it. :sweat_smile:

In the latter case it’s not going to immediately affect the working tree, but it may give you weird errors when trying to work with the repository.

Thank for your reply. I have committed, pushed and pulled after the deletion, and I haven’t seen any error message. I hope that possible problems caused by the deletion have not affected the main repository.

I will keep the current working tree as a backup, and continue to work with another working tree obtained after cloning the repository.

The remote should do consistency checks while receiving the push, so that should be fine. And if you don’t have things like local-only branches you that don’t want to lose a fresh clone is a good way to make sure your local repository isn’t damaged. :slightly_smiling_face:

You don’t exclude that some information could have been lost, right? I have quickly checked but I haven’t found any lost so far…

Remotely definitely not, unless you did anything that required a force
push. Locally it again depends on the file, if you want to check if the
commit history is okay you could try using git fsck.