eclipse上传项目到github上

GitHub 是一个面向开源及私有软件项目的托管平台,因为只支持 Git 作为唯一的版本库格式进行托管,故名 GitHub。
作为一个开源项目的聚集地,gthub一直收到开发者的青睐,那么我们要如何把自己的项目上传到github上面呢,下面我将向大家介绍一下在eclipse中开发的项目如何上传到github上。

1. 准备工作
(1)注册github的账号
首先需要到github的官方网站上注册个人账号
官网https://github.com/
注册的过程中只要填写好自己的信息就可以了。
(2)安装eclipse的git插件
要在eclipse上使用git工具,那么我们需要在eclipse上安装egit插件。
点击help->install new software进行安装
插件下载URL: http://download.eclipse.org/egit/updates
插件安装完成后,我们还需要进行eclipse的git账号配置
windows->preference
然后输入git 选择Configuration,然后输入自己在github上面的email和name
eclipse上传项目到github上
(3)添加github的ssh认证
github上面对上传用户会进行ssh的认证,为了不用每一次上传项目就需要输入用户名和密码,我们需要在github上面添加认证。

首先在eclipse上面找到eclipse客户端的ssh key
windows->preference 然后输入ssh
eclipse上传项目到github上
keymanagement->Generate RSA key
然后复制rsa key

然后到github上面,点击setting->SSH and GPG keys
然后点击new sshkey,输入刚才复制的key,添加就可以了

eclipse上传项目到github上

2. 上传案例
上面的准备工作完成后,我们就可以进行上传了。下面我们进行一个简单的案例。
(1)新建项目
新建一个项目,并写几句代码,因为空项目是不能上传的。
eclipse上传项目到github上

(2)创建本地库
然后点击右键 ->team->share project
eclipse上传项目到github上

这里记得勾选 use or create repository in parent folder of project,这个选项表明可以在原项目上进心git配置,这样子我们就可以不用再其他的目录新建本地库了。
然后点击create repository
点击Finish

这样子,我们就新建了一个本地git库了。

(3)创建github remote responsitory
下面我们需要在github上面新建一个remote reponsitory,用来存储我们的项目
点击右上角的加号->new repository
填写reponsitory的名字
eclipse上传项目到github上
点击create responsitory按钮就可以了
eclipse上传项目到github上

然后我们复制 responsitory的地址https://github.com/hugua/Main.git
(4)上传到github
下面我们回到eclipse
右键->team->add to index
这样子我们就把文件加入到git库中了
然后再点击右键->team->commit
eclipse上传项目到github上
在 commit message中输入本次修改的信息,这里我们输入test吧
然点击 commit and push
填写提交的信息eclipse上传项目到github上
点击next
eclipse上传项目到github上

source ref和destination ref都选择如下
eclipse上传项目到github上
点击add spec
然后点击finish
等待提交成功的提示,这样子,我们就成功得把项目上传到github上面了。