pitosalas
pitosalas

Reputation: 10902

Does the target directory for a git clone have to match the repo name?

In other words, I have a repo up on Github called st3_packages (https://github.com/pitosalas/st3_packages).

I want to do a git clone and have it create a directory on my local computer called "Packages".
Is that possible?

Upvotes: 1

Views: 2145

Answers (1)

VonC
VonC

Reputation: 1329322

Yes, it is possible:

git clone https://github.com/pitosalas/st3_packages Packages

You can specify the local root directory when using git clone.

<directory>

The name of a new directory to clone into.
The "humanish" part of the source repository is used if no directory is explicitly given (repo for /path/to/repo.git and foo for host.xz:foo/.git).
Cloning into an existing directory is only allowed if the directory is empty.


As Chris comments, you can then rename that top directory.
Git only cares about the .git within said top folder, which you can get with various commands:

git rev-parse --show-toplevel
git rev-parse --git-dir

Upvotes: 7

Related Questions