EGit与github使用教程

最近好多人在讨论git,以前只用过svn,听说git比svn好用很多,所以今天研究了一下关于git的使用,包括如何将代码上传到github.com,如何使用Eclipse的git插件EGit。

Mark一下!

一、配置Git环境

1、上官网(http://git-scm.com/)下载最新版的git,并安装

2、双击Git Bash程序,进入命令窗口

3、检查是否配置过ssh

ssh -T git@github.com

#若出现以下结果则表示配置过
Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.

4、配置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 known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
Connection closed by 207.97.227.239

继续测试

$ ssh -T git@github.com
Permission denied (publickey).

输出无权限,需要为本机生成公钥,执行命令:

$ ssh-keygen

输出结果

Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
4c:19:5d:01:9a:94:e7:ac:62:cf:xx:xx:xx:xx:xx:xx Administrator@GEVIN

从上图中可以看到公钥已经生成,保存在c/Users/Administrator/.ssh/id_rsa.pub

用记事本打开id_rsa.pub,复制里面的内容

登录github.com,打开https://github.com/account/ssh,将复制过来的公钥添加到里面

继续测试

ssh -T git@github.com
# 成功输出
Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.

不懂之处或出现其它问题,请参考:http://help.github.com/ssh-issues/

二、安装Eclipse EGit

打开http://www.eclipse.org/egit/download/,下载egit插件

Eclipse安装插件方法:Help — Install New Software — add — 输入Name,Location选择下载的egit插件文件(.zip结尾) — OK — 继续安装

三、如何使用egit创建本地仓库

内容太多了,这里就不写了,呵呵!!

请参考官方文档:http://wiki.eclipse.org/EGit/User_Guide/Getting_Started

四、如何将Eclipse创建的项目上传到github.com上面

请参考官方文档:http://wiki.eclipse.org/EGit/User_Guide#Github_Tutorial

 

本文固定链接: http://gevin.me/182.html | Gevin's Blog

该日志由 admin 于2012年02月09日发表在 Java 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: EGit与github使用教程 | Gevin's Blog
关键字: ,

EGit与github使用教程:等您坐沙发呢!

发表评论

快捷键:Ctrl+Enter