目前windows版本的git有几种实现,但咱们选择msysgit发行版,这是目前作得兼容性最好的。下载地址:http://code.google.com/p/msysgit/downloads/listnode
下载完成后双击安装文件并按照提示完成git的安装。git的安装过程十分简单,安装完毕后会提示你作初步的配置工做,这里咱们所有按照默认值便可(PS:在选择git bash时我选择了类unix提示界面),安装完毕后在桌面找到快捷方式打开。git
github是一个相似sf的免费项目管理及分享的服务平台,要想使用github提供的服务,你必须先注册成为github注册用户。github的网址是:http://github.comgithub
在C盘下建立目录git_repository(后续的项目均可以集中放在git_repository中),能够经过在git bash中执行如下命令完成:web
1 |
cd /c |
2 |
mkdir git_repository |
在git bash中执行如下命令完成:shell
1 |
ssh -keygen |
一路按Enter键便可,固然若是你想选择使用密码功能,那么在提示输入密码是选择你本身的密码。过程以下图所示:windows
注意:生成的秘钥在C:\Users\32219\.ssh----id_rsa.pub,文本打开文件,copy全部。bash
登录github系统。点击右上角的Edit your profile---> Account Settings--->SSH Public keys ---> add another public keys,把你本地生成的密钥复制到里面(key文本框中), 点击 add key 就ok了。ssh
测试链接是否成功,在git bash中执行如下命令完成:ide
1 |
ssh -T git@github.com |
提示以下信息说明链接成功:测试
Hi BoBoBo111! You've successfully authenticated, but GitHub does not provide shell access.
project :hello-world
description : my first project
点击“Create Repository” ;如今完成了一个项目在github上的建立。
1 |
$ makdir ~/hello-world //建立一个项目hello-world |
2 |
$ cd ~/hello-world //打开这个项目 |
3 |
$ git init //初始化 |
4 |
$ touch README |
5 |
$ git add README //更新README文件,若是其中有多个文件,输入命令 git add . |
6 |
$ git commit -m " first commit" //提交更新,并注释信息“first commit”,注意是双引号,而非单引号 |
7 |
$ git remote add origin git@github.com:BoBoBo111/hello-world.git //链接远程github项目 |
8 |
$ git push -u origin master //将本地项目更新到github项目上去 |
如今查看github上面的hello world 项目,是否是发现已经将本地中的README文件更新上来了。 :) 恭喜!