简体   繁体   中英

git clone into home directory

$ git clone ssh://host/repo.git ~/
destination directory '/home/username/' already exists.

Can anyone tell me how to make this work? I'm trying to quickly be able to replicate common dev scripts and config.

This seems to work:

cd ~
git init
git remote add origin ssh://host/repo.git
git pull origin master

The clone command creates a new directory when you pass a second argument:

$ git clone ssh://host/repo.git ~/your_directory

clone will create ~/your_directory . If the directory already exists it will give you the error you get.

cd ~
git clone ssh://host/repo.git

After that, you have the project in the /home/username/repo/ directory

If you want to have the project in a different folder name (eg 'foo/')

mkdir ~/foo
cd ~/foo
git clone ssh://host/repo.git foo/

I would clone the repository into a subdirectory:

git clone ssh://your/git/repo.git ~/repo

And create symlinks to the configuration files:

ln -s ~/repo/.bashrc ~/.bashrc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM