Git相关操作及记录

一、软件

1、下载Git客户端软件

Widows平台:

https://github.com/git-for-windows/git/releases/download/v2.13.0.windows.1/Git-2.13.0-64-bit.exe

Mac OS X系统:

https://sourceforge.net/projects/git-osx-installer/files/git-2.13.0-intel-universal-mavericks.dmg/download?use_mirror=autoselect

2、TortoiseGit

安装包:

https://download.tortoisegit.org/tgit/2.4.0.0/TortoiseGit-2.4.0.2-64bit.msi

语言包:

https://download.tortoisegit.org/tgit/2.4.0.0/TortoiseGit-LanguagePack-2.4.0.0-64bit-zh_CN.msi

二、Git SSH Key 配置

1、SSH Key 生成

a) 检查本机是否已经存在SSH Key:cd ~/.ssh

 Git相关操作及记录

b) 设置Git的user name和email:

$ git config --global user.name "zhoumingjun"

$ git config --global user.email "zhoumingjun@purang.com"

c) 生存密钥:$ ssh-keygen -t rsa -C “zhoumingjun@purang.com”  

3个回车,密码为空。如下图:

 Git相关操作及记录

d) 此时在windows用户下生成2个密钥文件:

 Git相关操作及记录

2、SSH Key 配置

a) 打开Bitbucket进入

 Git相关操作及记录

b) 添加SSH Key

将本地的公钥用文本打开全选copy,然后copy到Bitbucket上

 Git相关操作及记录

保存之后,此时生成了一条SSH Key记录

 Git相关操作及记录

三、Git 命令使用

1、获取源码,git clone  ssh://git@10.1.110.21:7999/pbq/pbq.git

 Git相关操作及记录

此时我的本地就已经有xxx的源码文件

 Git相关操作及记录

2、添加一个文件c.txt,git add

 Git相关操作及记录

3、将文件提交到仓库 git commit

 Git相关操作及记录

4、推送本地更新到远程 git push

 Git相关操作及记录

5、更新远程更新到本地 git pull

 Git相关操作及记录

6、添加多个文件git add -A

 Git相关操作及记录

7、删除文件及文件夹 git rm

 

 Git相关操作及记录

四、TortoiseGit使用

1、获取源码 git clone

 Git相关操作及记录

找到TortoiseGit安装的目录下找到puttygen.exe文件运行,选择通过git bash 生成的id_rsa密钥文件

 Git相关操作及记录

Git相关操作及记录

然后保存带有.ppk后缀的文件名:id_rsa.ppk

 Git相关操作及记录

右键Git clone,选择刚刚保存的私钥,点击OK,即可获取源码。

2、添加文件

右键TortoiseGit Add

Git相关操作及记录

点击Commit

 Git相关操作及记录

Git相关操作及记录

选择Commit&Push 即可提交文件

3、更新远程更新到本地

 Git相关操作及记录

Git相关操作及记录

4、其他操作:添加多个文件、撤销Commit等操作等都是图形化操作。