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

Eclipse 的git相关配置

2015-09-01 11:48 537 查看

下载安装git插件

打开eclipse,点help—–install newsoftware,名字写EGit,

链接地址:http://download.eclipse.org/egit/updates,安装完毕后重启Eclipse。

配置eclipse

点击window—sharepreference—Team—Git—-Configuration,在user settings栏目点击Enter Entry,添加user.name 和user.email

新建工程建立本地git仓库

右键点击项目—Team—-share project,点击create,点Browser选中刚才建的放仓库的路径,这就是我们真正放仓库的地方。

在这里有一个选项Use or create respository in parent folder of project(将项目的父文件夹作为仓库或新建一个),建议不选。完成后项目会被移动到指定仓库的路径下

进入github建立项目

https://github.com/

配置eclipse和github密钥

window → preference → general → network connection → SSH2 → Key Management → generate RSA Key… → apply → save private key…或者使用已有的git密钥,将Eclipse 中的RSA Key复制到github 中settings→SSH Key→Add SSH Key

commit修改

右键点击项目Team–commit,写上注释选择所有代码,然后commit,commit到本地之后代码里 no head变成了master,表示本地有分支了

Eclipse的git 配置关键步骤

这个时候如果你点team–remote–push,无论怎么配是不会成功的,注意那个填URI的地方只能填http地址,填git地址识别不出来。即便这样填好http之后,push时会提示no fast farward之类的,意思是应该先从github上pull一下,然后再push。当你pull时,又会马上提示各种没配置好。这时可以按如下操作:点window—preference–team—git–configuration—Repository Settings,Repository选择项目所在路径,然后点右边的open

将config修改为以下状态:

[core]

repositoryformatversion = 0

filemode = false

bare = false

logallrefupdates = true

symlinks = false

ignorecase = true

hideDotFiles = dotGitOnly

[remote “origin”]

url = (github中的git地址)

fetch = +refs/heads/:refs/remotes/origin/

[branch “master”]

remote = origin

merge = refs/heads/master

[user]

name = 名字

email = email

注意:那个url地址是你在github上建库的ssh地址。

如果不修改这个config文件,在点push后会有提示配置Custom URI,根据提示就好。有些Eclipse版本会更具URI自动填写账号,导致选择protocol类型为git时账号不能自己输入。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: