0%

SourceTree和GitLab配合使用的问题

问题描述

在使用SourceTree管理GitLab的时候出现了无法添加Repository

1
This is not a valid source path / URL

或者无法Pull or Push的情况。

1
2
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.xxx/xxx.git/'

解决办法

首先在添加或者pull/push的时候需要使用对应的Clone with SHH的地址如:“git@gitlab.xxx/xxx.git”,而不是Clone with HTTPS的地址。

如图:

其次,在MacOS中,SourceTree的Preference中并不提供指定公私钥的配置。我们需要在生成公私钥的时候对私钥进行ssh-add,如:ssh-add id_rsa

同时在公司gitlab页面上设置好SSH使用的私钥对应的公钥。

Reference

Mac 下source tree 与 gitlab 添加 ssh 密钥