13

I'm trying to use git clone to download the codes from my webfaction server

$ cd ../webapps/nameofwebapp/
$ git clone git@github.com:github-username/github-repo.git ./

AND there is error :

fatal: destination path '.' already exists and is not an empty directory.

I use ls and there are something under the nameofwebapp

auth  git.cgi  gitweb.cgi  repos  static

I want to ask where to use git clone Do I need to make a new directory??

jub0bs
  • 60,866
  • 25
  • 183
  • 186
user2492364
  • 6,543
  • 22
  • 77
  • 147

3 Answers3

5

Simply:

git clone git@github.com:github-username/github-repo.git

That will create a new folder github-repo in ../webapps/nameofwebapp/.

In your case:

cd ../webapps/nameofwebapp/
git clone git@github.com:github-username/github-repo.git -b develop ./

If you already did the clone:

cd github-repo
git checkout -b develop origin/develop
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • it works but seems it clone the wrong branch.there are tow branches on git.master and develop.and I want to clone develop – user2492364 Aug 31 '14 at 11:33
  • now my git branch only have "master".I want to delete it and retry your "git clone git@github.com:github-username/github-repo.git -b develop ./" can you teach me how to remove the github-repo directory – user2492364 Aug 31 '14 at 11:42
  • @user2492364 you can remove the folder. But I have fixed the checkout command. Give it a try. – VonC Aug 31 '14 at 11:43
  • @user2492364 yes, the `clone` command clones *all* branches in the `origin` namespace. You just need to create the one you need from one of those `origin/xxx` branches. – VonC Aug 31 '14 at 11:49
1

Maybe you have a same name git project directory in current path, git clone command will create a new directory and will crash if there is a same name directory.

0

The issue for me was related to SSH keys. When I set the key, it worked fine.

Hedego
  • 276
  • 2
  • 12