2

I uses macOS and Ubuntu. I want to git clone a certain project https://github.com/Project/project.git to a specific directory $HOME/git. I saw this page: How do you clone a Git repository into a specific folder?, but it requires to explicitly specify its project name like: git clone https://github.com/Project/project.git $HOME/git/project. How can I git clone them without specifying its project name?

[Add1] If I git clone like: git clone https://github.com/Project/project.git $HOME/git then I encountered fatal: destination path '/home/paalon/git' already exists and is not an empty directory. [Add2] I want to clone git-managed projects under $HOME/git directory. I want to set the state ls $HOME/git shows like project1/ project2/ project3/.

Paalon
  • 63
  • 1
  • 2
  • 6
  • 1
    Possible duplicate of [How do you clone a Git repository into a specific folder?](https://stackoverflow.com/questions/651038/how-do-you-clone-a-git-repository-into-a-specific-folder) – jonrsharpe Nov 16 '18 at 15:21

4 Answers4

7

How do you clone a Git repository into a specific folder?

The git clone command can be used in the following way:

 git clone <url> <destination>

fatal: destination path /home/paalon/git already exists and is not an empty directory.

This is due to the face that you already have folder with the given name /home/paalon/git.
Delete the "old folder" and clone again, this time add the desired path to your clone command

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
2

Split into 2 commands:

cd $HOME/git
git clone https://github.com/Project/project.git

That way you name the project only once.

phd
  • 82,685
  • 13
  • 120
  • 165
2
git -C $HOME/git clone https://github.com/someorg/Boostnote.git

will create $HOME/git/Boostnote

ErgoZ
  • 31
  • 2
0

I don't think that's actually correct. You can clone providing any directory as your target. It doesn't have to match the project name:

$ git clone https://github.com/eantoranz/bwv blahblah
Cloning into 'blahblah'...
remote: Enumerating objects: 221, done.
remote: Total 221 (delta 0), reused 0 (delta 0), pack-reused 221
Receiving objects: 100% (221/221), 62.45 KiB | 480.00 KiB/s, done.
Resolving deltas: 100% (150/150), done.`1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • I get the following error: `$ git clone https://github.com/BoostIO/Boostnote.git $HOME/git` `fatal: destination path '/home/paalon/git' already exists and is not an empty directory.` – Paalon Nov 16 '18 at 15:24