Git:使用父层次结构克隆仓库 [英] Git: Cloning repo with parent hierarchy
问题描述
我有一个~/git
目录,我将在其中复制的所有内容都克隆到该目录中.
为了使事情简单和井井有条,我镜像了远程目录结构.
因此https://gitlab.com/ajak/tuir
将被克隆到~/git/gitlab.com/ajak/tuir
中.
I have a ~/git
directory, into which i clone everything i work on.
To keep things simple and organized, i mirror the remote directory structure.
So https://gitlab.com/ajak/tuir
would be cloned in ~/git/gitlab.com/ajak/tuir
.
我创建了一个bash脚本,该脚本在不同情况下都无法运行,我想知道我是否只是错过了正确的命令.
I created a bash script which broke under different circumstances and i wondered, if i was just missing the right command.
有没有一种方法可以用一个命令优雅地完成此操作,而不是手动创建此结构?
Is there a way to do this elegantly with one command, instead of creating this structure by hand?
看来我忘了提及一些信息.
有时我想通过ssh克隆,有时想通过https克隆.
因此网址可以是git@gitlab.com:ajak/tuir.git
或https://gitlab.com/ajak/tuir.git
.
我猜一旦可以在合适的计算机上进行挖掘,我就会坚持使用脚本.
it seems i forgot to mention some information.
Sometimes i want to clone via ssh and sometimes https.
So the urls could be git@gitlab.com:ajak/tuir.git
or https://gitlab.com/ajak/tuir.git
.
I guess i'll stick to a script, once i can dig it up on the right computer.
推荐答案
如果您使用的是Bash,则可能需要尝试类似的操作
If you're using Bash you may want to try something like
FOO="gitlab.com/ajak/tuir" bash -c 'git clone https://$FOO $FOO'
或在您的.bashrc
function foo() {
git clone https://$1 $1
}
并致电foo gitlab.com/ajak/tuir
.
这篇关于Git:使用父层次结构克隆仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!