下载地址:https://git-scm.com/downloads

自建git项目管理库及ssh方式使用

 

 自建库后企业内部帐号与github帐号冲突,为了解决多个git帐号冲突,方法如下。

步骤一:设置全局用户名,邮箱

$ git config --global user.name "xxxx "
$ git config --global user.email "xxxxx@xxxxxxx.xxxx"

步骤二:生成ssh-keygen,示例如下

$ ssh-keygen -t rsa -C "xxxxx@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/SPB_Data/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in i:/git/xxxxx.
Your public key has been saved in i:/git/xxxxx.pub.
The key fingerprint is:
xxxx  
   

重复步骤一,二

注意:可以不设置密码

形成4个文件

自建git项目管理库及ssh方式使用

 

 

 上传到带.pub的文件到自建git服务器上,位置如下

自建git项目管理库及ssh方式使用

 

 

 

本地git上传下载

方式一:

ssh-agent bash
$ ssh-add "C:\Users\zgj\.ssh\生成的两个文件中的不带pub的那个"

方式二:  

去用户 /用户名 /.ssh 目录

添加一个config文件,其他文件删除,config文件内容如下

增加多个如下配置节

Host gitlab.xxxx.com
HostName gitlab.xxxx.com
User zhaogaojian
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_xxxx

注意:

1、Host后面要填写实际打开git首页地址,比如gitlab.xxxx.com不能写成xxxx.com

不然后面会一直access denied

2、IdentityFile不要用那个带.pub的文件,.pub是公钥文件,需要上传到服务器上用。

测试clone成功

自建git项目管理库及ssh方式使用

 

相关文章:

  • 2022-12-23
  • 2022-02-22
  • 2022-01-10
  • 2021-11-03
  • 2021-08-28
  • 2021-09-20
  • 2021-04-13
  • 2021-06-10
猜你喜欢
  • 2022-01-14
  • 2021-08-24
  • 2022-12-23
  • 2021-07-14
  • 2021-07-08
  • 2022-01-14
  • 2022-12-23
相关资源
相似解决方案