1

There are at least 3 previous questions explaining how to clone a repository without the .git directory:

From those questions, it seems you can't just run git clone and have the repository cloned without the .git directory.

Yet, in the majority of repos I've cloned, such as the one in the command below, no .git directory is made.

git clone https://github.com/scotch-io/scotch-box.git

What determines whether a straight forward git clone command creates a .git directory or not?

Community
  • 1
  • 1
CL22
  • 14,026
  • 26
  • 90
  • 153
  • 1
    Well after I cloned the repo given by you, I have a `.git` directory. So the only situation I can imagine where you don't have a .git directory is a bare repository. But even if you clone this bare repo git will create a .git folder. It is mandatory for git to work properly. – ckruczek Aug 12 '15 at 12:11
  • possible duplicate of [Do a "git export" (like "svn export")?](http://stackoverflow.com/questions/160608/do-a-git-export-like-svn-export) – CL22 Aug 13 '15 at 08:21
  • Never seen a git repository without the `.git` directory. Not possible. Probably just hidden in your case. – Rohan Aug 07 '20 at 12:04

2 Answers2

4

There is always a .git directory after a git clone. No exception. If you don't see it then it is hidden (How this happens depends on your operating system. ls on linux does not show files/dirs that start with a dot. You would have to use ls -a.)

The .git directory is essential as it contains all files and info used by git.

Here is what happens after the git-clone you mentioned:

/tmp % git clone https://github.com/scotch-io/scotch-box.git
Cloning into 'scotch-box'...
remote: Counting objects: 83, done.
remote: Total 83 (delta 0), reused 0 (delta 0), pack-reused 83
Unpacking objects: 100% (83/83), done.
Checking connectivity... done.
/tmp % cd scotch-box 
/tmp/scotch-box (git)-[master] % la
total 40K
drwxr-xr-x 4 t t 4.0K 12. Aug 14:10 .
drwxrwxrwt 8 root  root   12K 12. Aug 14:10 ..
drwxr-xr-x 7 t t 4.0K 12. Aug 14:10 .git
-rw-r--r-- 1 t t   18 12. Aug 14:10 .gitignore
-rw-r--r-- 1 t t 7.4K 12. Aug 14:10 README.md
-rw-r--r-- 1 t t  480 12. Aug 14:10 Vagrantfile
drwxr-xr-x 2 t t 4.0K 12. Aug 14:10 public
toydarian
  • 3,642
  • 5
  • 18
  • 33
2

Are you sure you are looking for .git in the right location? When you do a clone like git clone https://github.com/scotch-io/scotch-box.git, the repo is actually clone in a directory scotch-box and hence .git will be at scotch-box/.git

On the other hand, doing:

git clone https://github.com/scotch-io/scotch-box.git .

note the . at the end - will clone in current folder (if that is not already a git repo)

manojlds
  • 275,671
  • 58
  • 453
  • 409