The short answer is: you don't.
The .git
directory is more or less a container for a bunch of metadata and local repository state tracking, which is read and written by the git
command. Much of the information stored there is specific to each person's local repository or stores data relating to mulitple branches, making it impractical to store that data in the remote repo which is why even when running git add .git
you won't see the directory staged for commit. THis answer gives a good overview of what is contained in the .git
directory: What is the .git folder
When you download a repository as a zip from github, it can't assume that you are looking for a git repository so it doesn't include one. If you have downloaded the zip you can add the .git
directory with git init
. This is only so helpful since it isn't hooked up to a remote repo yet. You can add the remote with git remote add <remote name> <upstream url>
.
However, all of this can be done by simply cloning the repo rather than downloading the zip.