3

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.

Jai Kotia
  • 166
  • 2
  • 16

2 Answers2

6

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?

kowsky
  • 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
  • 1
    My 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
2

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).

jdno
  • 4,104
  • 1
  • 22
  • 27