有没有办法在一个命令中使用用户名和密码从 gitlab 克隆?

Is there a way to clone from gitlab with username and passwordr in one command?

这个 post 的解决方案不起作用 How to provide username and password when run "git clone git@remote.git"?

git clone https://username:password@github.com/username/repository.git

严重:无法访问'http:/..: 无法解析主机:用户名

Gitlab 不支持在一行中使用 http 进行克隆。也许你可以用 ssh 做到这一点?

有一些 git 服务可以在一行中使用 http 克隆。例如 Github 和 Gitorious。 我认为 Gitlab 只支持用户名前缀。总是会询问密码。这也带来了巨大的安全优势,因为通过这种方式,您的密码永远不会存储在日志文件中。

是的,你可以。语法是:

git clone https://username:token@gitlab.com/user/repo.git

其中 username 是您的 Gitlab 用户名,token 是通过您的 Gitlab 的 settings > Access Tokens

生成的