I have done git init and created a Git Repository for my project. When I "cd .git" I enter the folder. But my problem is that in the Git Repository the .git file does not get uploaded. I tried changing directory and doing a fresh git init, but the problem persists. As a result when someone clones my Repository, there is no .git folder and hence it says not a Git repository.
-
How did you upload the git repository? – rlee827 Mar 10 '18 at 05:50
-
via VCS import in Android Studio. I did a git status and pushed some commits as well, but the .git file is not on the repo. Link: https://github.com/JaiKotia/NewsMap – Jai Kotia Mar 10 '18 at 05:59
-
Post content of .git/config file – Sumit Mahamuni Mar 10 '18 at 06:00
-
@SumitMahamuni here: [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true – Jai Kotia Mar 10 '18 at 06:05
-
1@JaiKotia, the `.git/` directory won't show up in GitHub's UI. Why do you want to see it there? (Note that the `.git/` directory is not tracked content: your `.git/` and GitHub's will be different.) – ChrisGPT was on strike Mar 10 '18 at 16:02
-
@Chris are we sure the OP is using github? – evolutionxbox Mar 10 '18 at 18:04
-
@evolutionxbox no, not sure since the question isn't very clear. But it's tagged with [tag:github]. – ChrisGPT was on strike Mar 10 '18 at 18:06
-
@chris that certainly would suggest its use. Only thing I don't understand... how can someone clone a repo and _not_ have the .git folder? – evolutionxbox Mar 10 '18 at 18:08
-
Did they actually clone the repo or just download it as a zip? – jdno Mar 12 '18 at 10:24
-
@jdno downloaded as zip. But isn't that option under "Clone" when you visit the repo on a website. It should be the same as "git clone" in terminal right? – Jai Kotia Mar 15 '18 at 12:21
2 Answers
The .git
folder never gets added/committed/pushed/uploaded. That's perfectly normal and not a problem at all. The .git
folder manages your local copy of your repository. Your repository on GitHub has its' own .git
folder, as has anyone cloning your repository. See this answer for a detailed explanation of what the folder contains.
The question that persists is why a person cloning your repository does get the not a Git repository
message. Did they cd
into the repository folder after cloning?

- 12,647
- 2
- 28
- 41
-
Yes I did cd into thier repository folder, but there was no .git folder. That's what confuses me. Command terminal also says "Not a git repository". – Jai Kotia Mar 13 '18 at 16:38
-
So they cloned the repo using `git clone`, all files where copied in the latest version, but the whole thing is no git repository?! – kowsky Mar 15 '18 at 08:04
-
1My bad, I assumed downloading file as .zip would set up a working git repository. Seems like git clone is the correct approach – Jai Kotia Mar 19 '18 at 15:48
On GitHub, you can either clone the repository or download it as a .zip
file. When you decide to download the directory, GitHub exports only the files you can see in GitHub's file browser, and it does not set it up as a Git repository. This is why there is no .git
folder, and why Git commands don't work in the extracted directory.
Downloading a repository as a .zip
file can be really useful when you don't care about the history and don't want to make any changes to the code. But when you want to collaborate, you need to properly clone the repository. If cloning the repository on the CLI is too complicated, check out the graphical UIs that exist for Git (e.g. GitHub Desktop, GitKraken, SourceTree just to name a few).

- 4,104
- 1
- 22
- 27