Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux GIT命令的问题_Linux_Git_Shell_Github - Fatal编程技术网

Linux GIT命令的问题

Linux GIT命令的问题,linux,git,shell,github,Linux,Git,Shell,Github,我正在尝试执行git clone命令从github存储库克隆源代码。我使用的是2.11.1版本。我运行的命令是 git克隆https://username:password@github.com/repository.git./localpath 这在windows机器上运行良好。但当我从linux执行时,机器命令正在删除@并抛出错误。执行失败就像 git克隆https://username:passwordgithub.com/repository.git ./localpath正在克隆到“.

我正在尝试执行git clone命令从github存储库克隆源代码。我使用的是2.11.1版本。我运行的命令是
git克隆https://username:password@github.com/repository.git./localpath
这在windows机器上运行良好。但当我从linux执行时,机器命令正在删除@并抛出错误。执行失败就像

git克隆https://username:passwordgithub.com/repository.git ./localpath正在克隆到“./localpath”。。。
错误:访问时无法解析主机用户名:passwordgithub.com


有人能帮我解决这个问题吗?

将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"

注意:对变量使用双引号

将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"

注意:对变量使用双引号

您是否尝试用\?您使用的是什么shell?@mipadi我使用的是bash shell。@user2773289与\一起工作时不使用\。失败。@user2773289,可能与未替换的密码冲突。您是否尝试使用\?您使用的是什么shell?@mipadi使用的是bash shell。@user2773289不使用\当我与jenkins一起工作时。失败。@user2773289,可能与未替换的密码冲突。我们已在linux上使用.netrc fiile和windows上使用_netrcfile修复了此问题。@Eldo很高兴您能够修复它!我们已在linux上使用.netrc文件和windows上使用u netrc文件修复了此问题。@Eldo很高兴您能够修复它!