美文网首页
Git 和 SourceTree

Git 和 SourceTree

作者: 武曌思 | 来源:发表于2017-10-28 09:58 被阅读0次

    一、Git 安装和环境配置

    感谢廖雪峰老师的博客,以下内容,有参考 Git教程

    1、下载适合的 Git,官网下载地址,请选择合适的操作系统及其位数。

    2、打开安装包,选择合适的安装路径,一路默认即可。注意:软件会在你选择的目录下新建一个 Git 文件夹作为最终的安装目录。

    3、配置。

    首先找到 Git Bash,在右键菜单中或者在开始菜单中都能找到

    然后输入以下命令,其中 name 和 email 处输入自己的GitHub信息

    git config --global user.name "Your Name"

    git config --global user.email "email@example.com"

    二、SourceTree 安装与配置

    1、安装

    (1)下载合适的 SourceTree,官网下载地址

    (2)打开安装包,等待出现以下界面。不要点击“继续”

    (3)配置免登陆 Atlassian 账户。因为这个账户需要翻墙,而且那个页面显示不出来(不知道什么原因)。

    感谢 xiofee 老师,以下有参考 SourceTree 免登录跳过初始设置

    首先找到用户目录下 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

        }

    ]

    (4)继续上面的安装。其中有两步,选择“跳过初始设置”和“我不想使用Mercurial”,因为我们配置了Git。如下图

    (5)安装成功,登录账户,愉快使用。

    三、Git 使用 ssh 秘钥

    感谢 superGG1990 老师,以下内容参考 初次使用git配置以及git如何使用ssh密钥(将ssh密钥添加到github)

    大致分为三步:

    一、生成密钥对

    二、设置远程仓库(本文以github为例)上的公钥

    三、把git的 remote url 修改为git协议

    四、使用

    1、提交->git commit,在提交选项中,可以选择不同的参数,例如“更改上一次提交”->git commit --amend

    2、抓取->git fetch

    3、重置提交->git reset,重置会有选项,分别对应参数soft,mixed(默认),hard

    重置提交选项

    4、回滚提交->git revert

    5、暂存文件->git add

    相关文章

      网友评论

          本文标题:Git 和 SourceTree

          本文链接:https://www.haomeiwen.com/subject/smpjpxtx.html