Git & TortoiseGit
2016-08-05 18:12
155 查看
http://www.git-scm.com/download/
http://download.tortoisegit.org/
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
指南
1. Getting Started
2. Git Basics
3. Git Branching
4. Git on the Server
5. Distributed Git
6. GitHub
7. Git Tools
8. Customizing Git
9. Git and Other Systems
10. Git Internals
ssh-keygen 使用帮助
Secure Shell key generator 工具,-t 指定加密算法类型(type),-b 指定密钥位数(bit) ,-C 注释(comment)
单独执行 ssh-agent -s 会得到命令行,然后再通过eval 执行这些命令行才能真正启动 ssh-agent,有点类似 js里的eval
如果提示 Could not open a connection to your authentication agent. 说明ssh-agent没有成功启动
补充:常用工具类所在目录结构
在当前用户目录(~)下创建 .profile 文件,内容是
1)生成 .ppk (可以通过PuTTYgen 生成新的密钥对,也可以load原有的私钥,转换成ppk)
![](https://images2017.cnblogs.com/blog/753930/201709/753930-20170925120639917-1953198101.png)
2) 通过 Pageant 工具加载 ppk
![](https://images2017.cnblogs.com/blog/753930/201709/753930-20170925120723682-921990552.png)
补充:tortoiseGit 目录结构
http://download.tortoisegit.org/
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
指南
1. Getting Started
2. Git Basics
3. Git Branching
4. Git on the Server
5. Distributed Git
6. GitHub
7. Git Tools
8. Customizing Git
9. Git and Other Systems
10. Git Internals
如何使用github
1) 通过Git Bash 生成公钥、私钥(RSA非对称加密算法)
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
$ ssh-keygen ? Too many arguments. usage: ssh-keygen [-q] [-b bits] [-t dsa | ecdsa | ed25519 | rsa] [-N new_passphrase] [-C comment] [-f output_keyfile] ssh-keygen -p [-P old_passphrase] [-N new_passphrase] [-f keyfile] ssh-keygen -i [-m key_format] [-f input_keyfile] ssh-keygen -e [-m key_format] [-f input_keyfile] ssh-keygen -y [-f input_keyfile] ssh-keygen -c [-P passphrase] [-C comment] [-f keyfile] ssh-keygen -l [-v] [-E fingerprint_hash] [-f input_keyfile] ssh-keygen -B [-f input_keyfile] ssh-keygen -D pkcs11 ssh-keygen -F hostname [-f known_hosts_file] [-l] ssh-keygen -H [-f known_hosts_file] ssh-keygen -R hostname [-f known_hosts_file] ssh-keygen -r hostname [-f input_keyfile] [-g] ssh-keygen -G output_file [-v] [-b bits] [-M memory] [-S start_point] ssh-keygen -T output_file -f input_file [-v] [-a rounds] [-J num_lines] [-j start_line] [-K checkpt] [-W generator] ssh-keygen -s ca_key -I certificate_identity [-h] [-n principals] [-O option] [-V validity_interval] [-z serial_number] file ... ssh-keygen -L [-f input_keyfile] ssh-keygen -A ssh-keygen -k -f krl_file [-u] [-s ca_public] [-z version_number] file ... ssh-keygen -Q -f krl_file file ...
ssh-keygen 使用帮助
Secure Shell key generator 工具,-t 指定加密算法类型(type),-b 指定密钥位数(bit) ,-C 注释(comment)
2)启动 ssh-agent
eval $(ssh-agent -s)
单独执行 ssh-agent -s 会得到命令行,然后再通过eval 执行这些命令行才能真正启动 ssh-agent,有点类似 js里的eval
3) 将私钥添加到 ssh-agent
ssh-add ~/.ssh/id_rsa
如果提示 Could not open a connection to your authentication agent. 说明ssh-agent没有成功启动
4)将公钥 (id_rsa.pub) 添加到 github
Settings -> SSH AND GPG keys -> New SSH key5)使用 ssh 地址进行clone等操作
git clone git@github.com:witaste/ztest.git
补充:常用工具类所在目录结构
│ git-bash.exe │ git-cmd.exe │ ├─cmd │ start-ssh-agent.cmd │ start-ssh-pageant.cmd │ └─usr ├─bin │ │ ssh-add.exe │ │ ssh-agent.exe │ │ ssh-keygen.exe │ │ ssh-pageant.exe
使用优化
因为每次启动 git-bash ,都需要启动一个新的 ssh-agent ,而且旧的不能用 ,能不能实现自动化呢,就是每次打开 Git Bash 就会自动打开ssh-agent并且自动将私钥添加到ssh-agent,答案是有第一种方案:
通过 GitHub Desktop 自带的 Git Shell 可自动完成第二种方案:
添加自动化脚本在当前用户目录(~)下创建 .profile 文件,内容是
env=~/.ssh/agent.env agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } agent_start () { (umask 077; ssh-agent >| "$env") . "$env" >| /dev/null ; } agent_load_env # agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then agent_start ssh-add elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then ssh-add fi unset env
第三种方案:
安装TortoiseGit 通过Pageant 软件加载PuTTY 形式的私钥1)生成 .ppk (可以通过PuTTYgen 生成新的密钥对,也可以load原有的私钥,转换成ppk)
![](https://images2017.cnblogs.com/blog/753930/201709/753930-20170925120639917-1953198101.png)
2) 通过 Pageant 工具加载 ppk
![](https://images2017.cnblogs.com/blog/753930/201709/753930-20170925120723682-921990552.png)
补充:tortoiseGit 目录结构
│ ├─bin │ pageant.exe │ puttygen.exe
相关文章推荐
- git与IDE开发[git for windows & TortoiseGit]
- Qt开发环境的搭建&加入Git做版本管理 :in Windows
- 分布式版本控制工具:git & mercurial
- Git系列之二 --- git-dir & work-tree
- git 客户端 tortoisegit
- 使用gitosis和tortoisegit打造自己的git服务
- 让Windows下Git和TortoiseGit支持中文文件名/UTF-8
- curl: (6) Couldn't resolve host 'android.git.kernel.org'
- Rails 3: Passenger can't find git gems || gem is not checkout Please run bundle install
- 解决git的这个错误:fatal: Unable to find remote helper for 'https'
- Linux 项目管理软件(svn & git……)代理设置
- Android & Android_X86的Git地址
- curl: (6) Couldn't resolve host 'android.git.kernel.org'
- Git -- 创建一个远程git仓库和做初始化"push"
- Git Push 错误 [remote rejected] master -> master (branch is currently checked out) & 无法查看push后的git中文件(转)
- Linux 项目管理软件(svn & git……)代理设置
- TortoiseGit入门(图文教程) Git,Github,puttygen,SSH
- 让Windows下Git和TortoiseGit支持中文文件名/UTF-8
- 关于git配合tortoiseGit的基础使用
- 使用gitosis和tortoisegit打造自己的git服务