How do you clone a Git repository into a specific

2019-01-03 03:23发布

Executing the command git clone git@github.com:whatever creates a directory in my current folder named whatever, and drops the contents of the Git repository into that folder:

/httpdocs/whatever/public

My problem is that I need the contents of the Git repository cloned into my current directory so that they appear in the proper location for the web server:

/httpdocs/public

I know how to move the files after I've cloned the repository, but this seems to break Git, and I'd like to be able to update just by calling git pull. How can I do this?

16条回答
冷血范
2楼-- · 2019-01-03 04:14

Make sure you remove the .git repository if you are trying to check thing out into the current directory.

rm -rf .git then git clone https://github.com/symfony/symfony-sandbox.git

查看更多
老娘就宠你
3楼-- · 2019-01-03 04:15

If you are using ssh for git cloning you can use the following command.

git -C path clone git@github.com:path_to_repo.git

eg: git -C /home/ubuntu/ clone git@github.com:kennethreitz/requests.git would pull the git repository for requests to your /home/ubuntu/ path.

查看更多
Lonely孤独者°
4楼-- · 2019-01-03 04:16

Option A:

git clone git@github.com:whatever folder-name

Option B:

move the .git folder, too.

Better yet:

Keep your working copy somewhere else, and create a symbolic link.

查看更多
SAY GOODBYE
5楼-- · 2019-01-03 04:19

Usage

git clone <repository>

Clone the repository located at the <repository> onto the local machine. The original repository can be located on the local filesystem or on a remote machine accessible via HTTP or SSH.

git clone <repo> <directory>

Clone the repository located at <repository> into the folder called <directory> on the local machine.

Source: Setting up a repository

查看更多
Deceive 欺骗
6楼-- · 2019-01-03 04:22

To clone to Present Working Directory:

git clone https://github.com/link.git

To clone to Another Directory:

git clone https://github.com/link.git ./Folder1/Folder2

Hope it Helps :)

查看更多
聊天终结者
7楼-- · 2019-01-03 04:23

If you want to clone into the current folder, you should try this:

git clone https://github.com/example/example.git ./
查看更多
登录 后发表回答