How to Delete Hidden Files on Mac

Go to the directory –

find . -name '*.DS_Store' -type f -delete

or,

sudo find / -name .DS_Store -delete;

To remove .git file –

rm -rf .git