
一、Eclipse上安装GIT插件EGit


EGit插件地址:
http://download.eclipse.org/egit/updates
OK,随后连续下一步默认安装就可以,安装后进行重启Eclipse
二、在Eclipse中配置EGit
Preferences > Team > Git > Configuration

注意这里的user.name 是你在https://github.com上注册用户名
user.email是你在github上绑定的邮箱。
(如果使用的是内网私库的话,这两个可以随意,但项目中最好使用名字拼音,区别对待。)
三、将本地项目提交到本地的GIT仓库中
1、项目右键-Team-Share Project



到此步,就成功创建GIT仓库。
2、配置.gitignore来排除这个文件夹(非必须)
打开Navigator窗口,在project根目录中添加.gitignore文件,将需要排除控制的目录写入.gitignore文件中:

这样git提交就过滤了一些不必要的文件,若是要过滤其他文件夹或文件直接在“.gitignore”中写,具体写法参考:
http://blog.csdn.net/u014079773/article/details/51602344
3、然后提交项目,commit
故通过Team -> Add to index可以将文件加入git索引,进行版本监控:



OK,这样代码提交到了本地仓库
四:将本地代码提交到远程的GIT仓库中
说明:此处的远程GIT仓库可以是github,也可以是自己搭建的私仓服务器(前提是私仓服务器已经部署,部署方法参考:Fresh.Qin:在CentOS下搭建私有的git服务器)。
1、在提交远程前,第一次先要建立一个空仓库
A、Github上,直接在页面上操作就行了;
B、私仓,上服务上使用以下命令建立
git init --bare Test.git
2、右键项目Team-Remote-Push 出现如下界面
填入私仓或者Github的地址信息:
以我的私仓地址为例:ssh://git@10.190.35.147/home/git/Test.git git/git




五:确认是否上传成功
A、github上直接去页面查看提交的分支信息即可;
B、私仓则可以进入对应目录后使用git log 确认,如下:
[root@perfgit Test.git]# pwd
/home/git/Test.git
[root@perfgit Test.git]# git log
