Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git clone without project folder

Tags:

git

linux

I have given access to server, and want to clone git repo into my root folder. But when I do git clone it will make me folder with project name, and my project folder is my root. I dont have access to my parent folder my root is

/var/www/sites/mysite/ 

and when I do cloning folder structure will be

/var/www/sites/mysite/mysite 
like image 854
dzona Avatar asked Jul 10 '13 21:07

dzona


People also ask

How do I clone a git repository without a directory?

You can specify the destination directory as second parameter of the git clone command, so you can do: git clone <remote> . This will clone the repository directly in the current local directory. This works only if current directory isn't empty.

Can I clone an empty repository?

You can now clone your new repository by doing the following: git clone /org/centers/foo/repos/private/bar Initialized empty Git repository in /tmp/bar/. git/ warning: You appear to have cloned an empty repository. As you can see, the --all created the remote master branch for you.

Can I clone a single folder from git?

Cloning only a subdirectory is not possible in Git. The network protocol doesn't support it, the storage format doesn't support it.


2 Answers

git clone accepts a last argument that is the destination directory, it is by default the name of the project but you can change it. In your case you probably want simply .:

$ git clone origin-url . 

But note that, from man git-clone:

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

like image 150
rodrigo Avatar answered Oct 30 '22 02:10

rodrigo


You can also just setup a new repo and then the tracking remote and branch:

git init . git remote add origin [email protected]:user/repo.git git fetch origin git checkout master 
like image 31
richo Avatar answered Oct 30 '22 01:10

richo