Linux git clone 到主目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9443927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git clone into home directory
提问by rich
$ 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.
谁能告诉我如何使这项工作?我正在尝试快速复制常见的开发脚本和配置。
采纳答案by rich
This seems to work:
这似乎有效:
cd ~
git init
git remote add origin ssh://host/repo.git
git pull origin master
回答by Sandro Munda
cd ~
git clone ssh://host/repo.git
After that, you have the project in the /home/username/repo/
directory
之后,你在/home/username/repo/
目录中有项目
If you want to have the project in a different folder name (e.g 'foo/')
如果您想将项目放在不同的文件夹名称中(例如“foo/”)
mkdir ~/foo
cd ~/foo
git clone ssh://host/repo.git foo/
回答by T Zengerink
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
回答by ouah
The clone command creates a new directory when you pass a second argument:
当您传递第二个参数时, clone 命令会创建一个新目录:
$ 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.
clone
将创建~/your_directory
. 如果目录已经存在,它会给你你得到的错误。