0

What is difference between two below scenarios.

  1. Running git clone on non empty folder named 'A' having no source control meta data i.e. no .git folder.

  2. Running git clone on non empty folder named 'B' having source control data i.e. having .git folder

Satish Pahuja
  • 209
  • 1
  • 6
  • 20

1 Answers1

0

As git clone will create a target directory to clone to by itself, and will create this as a sub-directory of A or B respectively, the only difference is that in the second case the cloned directory will show up as an untracked directory in B. Note that Git does not recognize the cloned repository as a git-submodule of B this way. If you wanted to do that, you'd need to use git submodule add instead.

sschuberth
  • 28,386
  • 6
  • 101
  • 146
  • the git clone is not allowed on non empty folder because of fear of loosing of existing contents of the directory. Am I correct? – Satish Pahuja Jul 23 '17 at 11:15
  • Not quite. Doing `cd B && git clone http://my/repo.git` works as it creates `B/repo/.git` in addition to `B/.git`, i.e. the `.git` directories are separate. You'll only run into problems if a directory called `repo` already exists in `B` before cloning. – sschuberth Jul 23 '17 at 11:32