现象如下:
使用TortoiseGit去拉本地GitLab上建立的项目时,一直提示输入密码(如下图),这个密码又没有指定用户名,就算你输入你用户名的密码也是失败。但是很诡异的是,你使用git bash又是能正常操作的,证明跟服务器的通信时ok的,例如如下的bash命令是正常运行的(将网址换成自己的项目网址):
ssh -vT git@192.168.0.108
解决方法:
https://stackoverflow.com/questions/8846972/tortoisegit-asking-password
上面这个网址给的解决方法是重新选择ssh的执行文件,但是这个方法我试过不行,因为我的git文件夹没有这个可执行文件。
第二种方法是指定密钥,但是是将gitlab的ssh密钥转换成PuTTY类型的密钥,然后在程序里面直接指定,方法具体如下(PuTTY工具在安装git的时候带了),后面就git就能正常用了:
If you need to use a username/password, there is a much simpler solution than the current #2 answer:
Right-click --> Tortoise Git --> Settings --> Git --> Credential --> Choose "Wincred, all Windows users" --> Hit apply
The next time you enter the password for a repo, that password will be automatically saved.
If you're using a repository that requires SSH keys rather than username/password (which it sounds like was OP's original issue), you need to
- Open the SSH key in PuTTY gen (installs itself alongside Tortoise Git)
- In PuTTY gen, save the key as a PuTTY key.
- In the repository,
Right-click --> Tortoise Git --> Settings --> Git --> Remotes
. Find your remote (usually 'origin') then load the PuTTY key from step 2.