您的位置:首页 > 编程语言

Windows 下使用 Github 第一步

2011-07-06 23:16 232 查看
进入 github.com 网站注册个账号 点 Pricing and Signup 申请,很容易申请到,不需要邮箱验证
登录账号 在仪表盘页面 找到

Set Up Git 这个对GIT的设置步骤非常详细,按着一步一步做

首先下载 Git for Windows.

http://code.google.com/p/msysgit/downloads/list


安装 一路NEXT 安装完成。
到开始菜单中找到 Git Bash 点击,跟DOS 页面一样,不过是linux下 shell的语法,
如下是我的
Welcome to Git (version 1.7.4-preview20110204)

Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

Lishiguang@XP-201106151358 ~
1、检查一下是否生成过SSH Key

$ cd ~/.ssh

Lishiguang@XP-201106151358 ~/.ssh
2、发现已经存在一个KEY
$ ls
id_rsa id_rsa.pub

3、将此SSHkey备份
Lishiguang@XP-201106151358 ~/.ssh
$ mkdir kye_backup
$ cp id_rsa* key_backup
cp: copying multiple files, but last argument `key_backup' is not a directory
Try `cp --help' for more information.
$ rm id_rsa*

4、KEY 已经备份好 并移除
Lishiguang@XP-201106151358 ~/.ssh
$ ls
kye_backup

5、生成自己新的KEY 后面是自己的邮箱地址 前面 固定格式
$ ssh-keygen -t rsa -C "alishiguang@gmail.com"
Generating public/private rsa key pair.
5.1 第一个回车 会将新KEY 生成到 下面的目录中
Enter file in which to save the key (/c/Documents and Settings/Administrator/.ss
h/id_rsa):
5.2 输入密码 并确认一次 生成新的KEY
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Documents and Settings/Administrator/.s
sh/id_rsa.
Your public key has been saved in /c/Documents and Settings/Administrator/.ssh/i
d_rsa.pub.
The key fingerprint is:
f3:c6:59:64:a4:b8:71:4e:49:57:1a:94:c9:65:d4:20 alishiguang@gmail.com

6 测试一下
Lishiguang@XP-201106151358 ~/.ssh
$ ssh -T git@github.com
The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of know
n hosts.
Enter passphrase for key '/c/Documents and Settings/Administrator/.ssh/id_rsa':

Permission denied (publickey).

添加您的SSH密钥,以GitHub上。在GitHub的网站点击“帐户设置” > 点击“SSH公钥” > 点击“添加其他公共密钥”
Lishiguang@XP-201106151358 ~/.ssh
$ git config --global user.name "alishiguang"

Lishiguang@XP-201106151358 ~/.ssh
$ git config --global user.email "alishiguang@gmail.com"

Lishiguang@XP-201106151358 ~/.ssh
$ git config --global github.user lishiguang

Lishiguang@XP-201106151358 ~/.ssh
$ git config --global github.token 88b35c88af0fd459550bb0f7c6c70b74

第一次更新一个文件 并上传
Lishiguang@XP-201106151358 ~/.ssh
$ mkdir ~/NoDB

Lishiguang@XP-201106151358 ~/.ssh
$ cd ~/NoDB

Lishiguang@XP-201106151358 ~/NoDB
$ git init
Initialized empty Git repository in c:/Documents and Settings/Administrator/NoDB
/.git/

Lishiguang@XP-201106151358 ~/NoDB (master)
$ touch README

Lishiguang@XP-201106151358 ~/NoDB (master)
$ git add README

Lishiguang@XP-201106151358 ~/NoDB (master)
$ git commit -m 'frist commit'
[master (root-commit) 9c4650c] frist commit
1 files changed, 8 insertions(+), 0 deletions(-)
create mode 100644 README

Lishiguang@XP-201106151358 ~/NoDB (master)
$ README
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: