我正在尝试执行git clone命令以从github存储库克隆源代码。我使用的是2.11.1版本。我运行的命令是git clone https://username:password@github.com/repository.git ./localpath
这在windows机器上很好用。但是当我从Linux机器执行命令时,命令是删除@并抛出错误。执行失败就像git clone https://username:passwordgithub.com/repository.git ./localpath Cloning into './localpath'...error: Couldn't resolve host username:passwordgithub.com while accessing
有人能帮我修一下吗?
最佳答案
将ssh keygen生成的id注册到github,这样它就不会提示您输入密码。
$ ssh-keygen
无需输入密码短语。输出您的公钥,然后将其复制到github
$ cat ~/.ssh/id-rsa.pub
但是,如果你真的想走那条路的话。
把它们放在一个报价单里,或者像下面这样做。
#!/bin/bash
REPO='https://username:password@github.com/repository.git'
LOCAL_PATH='path/to/wherever'
git clone "$REPO" "$LOCAL_PATH"
注意:变量使用双引号
关于linux - GIT命令问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42656643/