首页   

SourceTree--破解(二)

无剑_君  ·  · 4 年前

一、SourceTree使用

破解:
找到目录:C:\Users\用户\AppData\Local\Atlassian\SourceTree
新建accounts.json文件里面输入:

[  
  {  
    "$id": "1",  
    "$type": "SourceTree.Api.Host.Identity.Model.IdentityAccount, SourceTree.Api.Host.Identity",  
    "Authenticate": true,  
    "HostInstance": {  
      "$id": "2",  
      "$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountInstance, SourceTree.Host.AtlassianAccount",  
      "Host": {  
        "$id": "3",  
        "$type": "SourceTree.Host.Atlassianaccount.AtlassianAccountHost, SourceTree.Host.AtlassianAccount",  
        "Id": "atlassian account"  
      },  
      "BaseUrl": "https://id.atlassian.com/"  
    },  
    "Credentials": {  
      "$id": "4",  
      "$type": "SourceTree.Model.BasicAuthCredentials, SourceTree.Api.Account",  
      "Username": "",  
      "Email": null  
    },  
    "IsDefault": false  
  }  
]  

二、SourceTree 添加 ssh key 方法:

1.使用 git 客户的生成公私钥:id_rsa、id_rsa.pub
1.1设置Git的user name和email:

$ git config --global user.name "xxx"
$ git config --global user.email "xxx.mail@xxx.com"

1.2.生成SSH密钥过程:
1.2.1.检查是不是已经存在密钥(能进去说明已经存在,就删掉文件夹,重新创建):
cd ~/.ssh
1.3.生成 SSH 密钥:
$ ssh-keygen -t rsa -C “xxx.mail@xxx.com
按3个回车,密码为空。
1.4.文件存放位置 ~/.ssh,如果是window的话就在:C:\Users\Administrator.ssh 下面,当然如果你不是 Administrator 用户的话,需要换成对应的用户。
2.设置 SourceTree 的 SSH客户端
1.配置SourceTree 的 SSH 客户的为:OpenSSH
1.1.工具->选项

image.png

一定要选OpenSSH:
OpenSSH

3.添加 ~/.ssh/id_rsa.pub 文件内容到 git 服务器里面去
3.1.比如你的 git 服务是https://code.aliyun.com,那么你需要在 https://code.aliyun.com/profile/keys
里面添加 SSH key

image.png

3.2.SourceTree 来下载 git 项目
3.2.1.复制你的 git 地址:git@code.aliyun.com:474177818/SoftwareCup.git
3.2.2.从 SourceTree 里面新建一个地址,这时候你发现你本地已经可以下载远程的 git 代码了

image.png

image.png

如果是阿里云代码操作如下:


image.png
$ git init
$ git remote add origin git@code.aliyun.com:474177818/SoftwareCup.git
$ git add .
$ git commit -am "初次提交"
$ git pull origin master:master

打开pull的代码:


image.png
image.png

4.解释:
1.ssh-keygen 是公钥私钥的非对称加密方式:
1.1.公钥:用于向外发布,任何人都能获取。
1.2.私钥:要自己保存,切勿给别人
2.公钥私钥加解密的原理
2.1.客户端把自己的公钥存放到要链接的远程主机上(相当于我们把自己的 id_rsa.pub 存放到 git 服务器上)
2.2.客户端要链接远程主机的时候,远程主机会向客户的发送一条随机的字符串,客户的收到字符串之后使用自己的私钥对字符串加密然后发送到远程主机,远程主机根据自己存放的公钥对这个字符串进行解密,如果解密成功证明客户端是可信的,直接允许登录,不在要求登录。

Git 全局设置
$ git config --global user.name "houjianjun"
$ git config --global user.email "474177818@qq.com"
创建新版本库
$ git clone git@code.aliyun.com:474177818/SpringBoot-train.git
$ cd SpringBoot-train
$ touch README.md
$ git add README.md
$ git commit -m "add README"
$ git push -u origin master
已存在的文件夹或 Git 仓库
$ git init
$ git remote add origin git@code.aliyun.com:474177818/SpringBoot-train.git
git add .
git commit
git push -u origin master
推荐文章
华泰固收强债论坛  ·  【华泰固收|转债】交科转债: ...  ·  4 年前  
观察者网  ·  又一家爆雷!四大民间高返平台全军覆没  ·  5 年前  
© 2022 51好读
删除内容请联系邮箱 2879853325@qq.com