Windows下git安装及使用技巧

来源:互联网 发布:淘宝嘉年华活动时间 编辑:程序博客网 时间:2024/06/05 15:15

1.       下载git软件

https://git-scm.com/

2.       安装git软装

Windows下git安装及使用技巧

Windows下git安装及使用技巧

Windows下git安装及使用技巧



Windows下git安装及使用技巧

Windows下git安装及使用技巧

Windows下git安装及使用技巧

Windows下git安装及使用技巧



Windows下git安装及使用技巧
Windows下git安装及使用技巧
Windows下git安装及使用技巧

3.       生成公私钥

Windows下git安装及使用技巧

 注:生成私钥的过程中,给私钥设定了密码保护。

Windows下git安装及使用技巧

注:将公钥(chenyan.pub)交给git 服务器的管理,把公钥及权限加入git服务器。

4.       git客户端连接git服务器的配置

--git服务器:用户名名

--git服务器::域名或IP地址

--git服务器:  端口

--git客户端: 私钥

Windows下git安装及使用技巧
注意:host 是别名

首次连接要建立互信并输入私钥的密码:

Windows下git安装及使用技巧

例子:(需要输入私钥密码)

Windows下git安装及使用技巧

     每次获取或上传远端git服务器时,都需要输入私钥密码。这样体验很不好,但又为了安全。

5.  实现一个想法,当电脑打开,打开迷你”Git Bash”,就要去输入私钥密码,然后保存起来,只要不重启电脑,可以反复启动“Git Bash”都不需要再次输入私钥密码。ssh-agent和ssh-add可以实现.为了方便编写一个脚本放在家目录中。

Administrator@Gengbiao MINGW64 ~

$ pwd

/c/Users/Administrator

Administrator@Gengbiao MINGW64 ~

$ cat .bashrc

 

SSH_ENV=$HOME/.ssh/environment

 

# start the ssh-agent

function start_agent {

      echo "Initializing new SSH agent..."

      # spawn ssh-agent

      /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"

      echo succeeded

      chmod 600 "${SSH_ENV}"

      . "${SSH_ENV}" > /dev/null

      /usr/bin/ssh-add ~/.ssh/chenyang

}

 

if [ -f "${SSH_ENV}" ]; then

     . "${SSH_ENV}" > /dev/null

     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {

        start_agent;

}

else

start_agent;

fi

--首次执行脚本需要输入私钥密码。

 Windows下git安装及使用技巧
--再次获取git clone是就不要私钥密码啦。

Windows下git安装及使用技巧

本文转自http://blog.sina.com.cn/s/blog_48f9c0840102whlq.html,所有权力归原作者所有。

0 0
原创粉丝点击