gitlab - 使用https推送,指定用户名和密码

cod*_*kix 6 git gitlab

我正在尝试将新创建的存储库推送到gitlab.这是我做的:

  1. 在gitlab中创建一个项目.示例网址:https://gitlab.example.com/examples/project1.git

  2. 发起了一个本地裸机:

    cd ~/projects
    git init --bare ./project1.git
    cd project1.git
    
    Run Code Online (Sandbox Code Playgroud)

题:

下一步是将我的所有本地repo推送到gitlab.但我想使用https指定用户名和密码.如何更改以下内容?

git remote add origin https://gitlab.example.com:group1/project1.git
git push --all
git push --tags
Run Code Online (Sandbox Code Playgroud)

cod*_*kix 19

像这里提到的其他人一样,ssh是首选.但对于那些只想使用http/https的用户,可以指定以下凭据:

git remote add origin https://username:password@gitlab.example.com:group1/project1.git
Run Code Online (Sandbox Code Playgroud)

已验证gitlab 9.0

注意:请用'%40'替换用户名中的'@'符号来处理此问题.

  • 在 gitlab.com 上,必须将冒号更改为斜杠才能使其正常工作:``https://user:pass@gitlab.com/group/project.git``` (4认同)