git clone without project folder

You can also just setup a new repo and then the tracking remote and branch, fetch all the objects on the origin repository and change to the master branch:

git init .
git remote add origin [email protected]:user/repo.git
git fetch origin
git checkout master

Remember that a git repository is simply the directory structure where you store it. This means that when you clone a repository into the wrong directory, you can simply move the directory contents anywhere else that you wish and the repository data is still intact. So for example, you can run the following commands from the command line:

$ mv /var/www/sites/mysite/mysite/* /var/www/sites/mysite`
$ mv /var/www/sites/mysite/mysite/.* /var/www/sits/mysite`
$ rmdir /var/www/sites/mysite/mysite

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.


This is working well on Windows also.

git init
git remote add origin [email protected]:user/repo.git
git pull origin master

Tags:

Linux

Git