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

 

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个回车,密码为空。如下图:

 

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

 

2、SSH Key 配置

a) 打开Bitbucket进入

 

b) 添加SSH Key

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

 

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

 

三、Git 命令使用

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

 

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

 

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

 

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

 

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

 

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

 

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

 

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

 

 

四、TortoiseGit使用

1、获取源码 git clone

 

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

 

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

 

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

2、添加文件

右键TortoiseGit Add

点击Commit

 

选择Commit&Push 即可提交文件

3、更新远程更新到本地

 

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

posted @ 2017-05-11 17:52  stonespawn  阅读(556)  评论(0编辑  收藏  举报