'How to create git archive of a subfolder and exclude hidden files?

I am able to successfully clone a git repository.

Now, I want to create a zip folder of the cloned project(which is a subfolder) and want to exclude .git and .gitignore folder/file.

I have so far written below but it is not excluding .git and .gitignore.

git archive -o project.zip HEAD subfoder/*


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source