---
title: "Eclipse下设置github开发环境"
author: "dcbjavaeye"
date: "2014-06-06T14:03:12Z"
tags: []
categories: ["开源软件"]
slug: "eclipse-github"
draft: false
lastmod: "2014-06-06T14:03:12Z"
id: 2076712
url: "https://dcbjavaeye.iteye.com/blog/2076712"
---

# 原址：

# http://www.cnblogs.com/terrylin/archive/2012/05/22/2513320.html

# [Eclipse下设置github开发环境](http://www.cnblogs.com/terrylin/archive/2012/05/22/2513320.html)

1.按照github上的指南配置（[http://help.github.com/win-set-up-git/](http://help.github.com/win-set-up-git/)）基础的git环境。

2.在github上创建一个Repository。

3.在Eclipse中通过“Eclipse Marketplaces”，在Market Places里安装egit。

4.在Eclipse中生public key, 并添加到GitHub Repository中。  
Eclipse中通过：performance -&gt; SSH2 -&gt; Key Management -&gt; Gernerate RSA Key 生成 SSH 的 public key。  
在GitHub中通过：edit your profile -&gt; ssh key -&gt; Add SSH Key 添加SSH Key, 把上面生成的 public key 拷贝到这里，保存。

5.Eclipse里File菜单，Import，即可从git导入刚添加到git的项目了。

6.修改，并提交。在项目上点右键–&gt;team–&gt;commit。commit是commit到本机的git库，而push才是同步到github。

 

 

在Eclipse中使用Egit插件

本地和远程的代码仓库都创建并且配置完成，接下来就是使用在Eclipse中使用Egit插件了。

如果你并不是一个管理员，你只需要将github服务器远程代码仓库clone或导入到本地。在Eclipse右键菜单Import选择Git-&gt;Projects from Git如图所示。

![](http://my.csdn.net/uploads/201204/05/1333594512_9254.jpg)

选择URI，这是意味着从远程服务器代码仓库导入一个工程。

 

![](http://my.csdn.net/uploads/201204/05/1333594516_9353.jpg)

在URI中输入git@github.com:tonyguan/Hello-Android.git。

![](http://my.csdn.net/uploads/201204/05/1333594523_3892.jpg)

 

点击下一步会有密码校验过程。

![](http://my.csdn.net/uploads/201204/05/1333594529_3610.jpg)

输入密码然后就很简单了，再做一些选择就可以导入工程了。

 

如果修改代码这文件就会处于未提交状态。

![](http://my.csdn.net/uploads/201204/05/1333594533_9583.jpg)

提交文件是通过选择工程右键菜单中的Team-&gt;Commit弹出提交对话框。在commit message中输入提交的注释信息。

![](http://my.csdn.net/uploads/201204/05/1333594542_3249.jpg)

点击Commit按钮就会提交这个文件了。

 

提交成功只是意味着，文件的变化保存到本地代码仓库中了，而没有推送到远程代码仓库。打开Eclipse的[]()[]()Perspective窗口选择Git Repository Exploring如图所示。

![](http://my.csdn.net/uploads/201204/02/1333362579_3302.jpg)

然后选择Hello-Android的Remotes-&gt;origin-&gt;git@github.com:tonyguan/Hello-Android.git。

 ![](http://my.csdn.net/uploads/201204/05/1333594562_6860.jpg)

右键选择菜单Push就开始向服务器推送本地代码了。

![](http://my.csdn.net/uploads/201204/05/1333594573_6962.jpg)