Paalon
Paalon

Reputation: 83

How to git clone with specifying the destination directory without its project name?

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

Upvotes: 3

Views: 16421

Answers (4)

ErgoZ
ErgoZ

Reputation: 31

git -C $HOME/git clone https://github.com/someorg/Boostnote.git

will create $HOME/git/Boostnote

Upvotes: 2

phd
phd

Reputation: 94483

Split into 2 commands:

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

That way you name the project only once.

Upvotes: 2

eftshift0
eftshift0

Reputation: 30212

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

Upvotes: 1

CodeWizard
CodeWizard

Reputation: 142094

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

Upvotes: 9

Related Questions