天天看点

gitbash配合github使用使用说明

使用说明

使用github当做远程库,用gitbash做同步工作。首先需要gitbash工具、github的库。这种同步解决方案与很多svn很类似。比如用tortoiseSVN同步代码到服务器是一样的。

gitbash工具官网可以下载,另外在github上新建repository,不用多说。

第一步:配置gitbash

配置一下gitbash和github的通信协议

桌面右键打开gitbash,

输入

ssh-keygen -t rsa -C "[email protected]":

回车后输入信息,可以直接一直回车下去。然后会在C盘-用户-xx-下有一个.ssh文件夹

里面有两个内容:id_rsa 、id_rsa.pub

记事本打开id_ras.pub,复制内容

打开github账户配置,点击ssh配置,新增sshkey,标题随便输入,内容粘贴到key里面,确认保存

在gitbash里输入

ssh –T [email protected]

即可验证是否配置成功

配置gitbash的用户名和邮箱:

git config –global user.name “用户名”
git config –global user.email “邮箱” 

           

配置完之后,gitbash命令行后面会多一个括号,显示master字样

第二步:新建github repository

新建项目,输入名称,点击clone or download 获取里面的下载地址

[email protected]:用户名/库名.git

第三步:本地与github链接

本地新建文件夹,打开gitbash

输入命令:

git init

初始化本地仓库

输入命令:

git remote add origin [email protected]:用户名/库名.git

远程连接

输入命令:

git pull [email protected]:用户名/库名.git

将github库同步到本地来

第四步:gitbash同步常用命令

//git add->git commit->git push 
git init //初始化仓库
git add 文件名 //新增单个文件 
git add . //新增全部文件
git commit -m "备注" //提交
git status //查看状态
git push //提交