Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Git to clone into current directory

Tags:

git

git-clone

I'm doing:

git clone ssh://[email protected]/home/user/private/repos/project_hub.git ./ 

I'm getting:

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

I know path . already exists. And I can assure that directory IS empty. (I do ls inside and I see nothing!)

What am I missing here in order to clone that project into the current directory ?

like image 575
MEM Avatar asked Mar 25 '12 22:03

MEM


People also ask

Can you git clone into an existing directory?

However, you can only clone into an existing directory only when it is empty. Otherwise, git will complain that the destination path already exists and is not an empty directory. That's all about cloning a Git repository into a specific folder.

How do I clone a repository to current directory?

Clone to the current directory To specify the current directory the symbol dot is used. So to clone repo to the current directory you need to specify two parameters to git clone: the url of the repo. just one symbol — dot — "." — it means current directory.

Why is git clone not copying source files to my local directory?

You might discover that the source files were there before, but were removed in a subsequent commit. If so, just git checkout to an older commit. Also possible that there's simply no files in the master branch ( git log --all will show other branches). See git branch for list and git checkout another branch.

How to clone a git repository into specific folder?

To clone a git repository into specific folder we use below command git clone <cloning_url> </fath/to/the/folder> Here we are mentioning where to clone the repository. so it will clone the repository into that specified path.

How to clone delftscopetech repository in Git?

Since the directory Delftscopetech already exists and contains some files, we cannot use the git clone command to clone our repository. If you don’t need the files in the directory, you can delete them, but if you want to merge the files in both repositories, use the method below.

What does Git clone--bare mean?

git clone --bare ¶ With the --bare argument passed to git clone, you will have a copy of the remote repo created with an excluded working directory. So, the repository will be created with the project history which can be pushed or pulled from but cannot be edited. git clone --mirror ¶

How do I know if a branch has been cloned in Git?

You can check the current branch cloned by running the “git branch” command. However, in some cases, you may want to clone a specific branch in order to start working. Your team may have chosen to let the “master” branch a bit behind and to have the most recent commits directly to the “dev” branch for example.


1 Answers

simply put a dot next to it

git clone [email protected]:user/my-project.git . 

From git help clone:

Cloning into an existing directory is only allowed if the directory is empty.

So make sure the directory is empty (check with ls -a), otherwise the command will fail.

like image 78
Roshan Pal Avatar answered Oct 06 '22 00:10

Roshan Pal