Github与Git使用

1、注册Github

注册完成之后会需要验证邮箱才能正常使用GitHub。

注册完成后,创建一个属于自己的库,包括库的名字,以及对库的介绍。

 

2、安装Git

首先进入Git官网www.git-scm.com下载适合自己电脑的版本,执行默认安装选项。

 

3、配置密钥

在本地创建ssh key并填写到Github网站,实现本地git与Github的认证连接。

1)执行命令:ssh-keygen -t rsa -C "[email protected]",邮箱为注册Github的邮箱,注意输入对应密码,其他选项可回车执行默认选项。

2)在c:/user/用户名/.ssh这个文件夹下找到id_rsa.pub文件复制密钥内容。

3)登录Github,在Setting——SSH and GPG Keys页面下点击New SSH Key按钮,取名,并粘贴密钥内容,保存。

4)执行命令,绑定用户信息:

ssh -T [email protected]

git config --global user.name “github-username”

git config --global user.email "you-email"

 

4、测试Git与Github连接

依次执行命令:

1)定位D盘根目录

cd  /D

2)创建文件夹

mkdir testProject

cd testProject

3)克隆代码库,增加代码并提交

git clone https://github.com/username/test.git

cd test

echo "No Content" > test.cpp

git add test.cpp

git commit -m "test commit"

git push origin master

4)提交完毕后,打开Github网站,查看Test项目是否增加代码文件test.cpp

 

 

 

 

 

 

你可能感兴趣的:(Github与Git使用)