在不提供密码和用户令牌的情况下进行 GitLab 操作的解决方法是使用 SSH 密钥进行认证。以下是一个代码示例:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
将生成的公钥(默认为 ~/.ssh/id_rsa.pub
)复制到 GitLab 的 SSH 密钥设置页面。
git clone git@example.com:your_username/your_project.git
cd your_project
git pull origin master
这样,你就可以使用 SSH 密钥进行 GitLab 操作,而无需提供密码和用户令牌。