Eclipise中,import〉Project from Git ,单击next
选中Clone URI, Next
输入uri,user,password,选择HTTP协议
Next,
选择要检出的分支
配置git参数:
Window > Preferences > Team >Git >Configuration
UserSettings > AddEntry
添加name和email
单击Apply保存
Window > Preferences > Team >Git >Configuration
Repository Settings
或者直接单击location右边的 open,出现一个config文件
复制以下内容进去即可
[core]
symlinks = false
repositoryformatversion = 0
filemode = false
logallrefupdates = true
[remote "origin"]
url = http://tech.pingansec.com/ulindows/project_ucs.git
fetch = +refs/heads/:refs/remotes/origin/
[branch "test"]
remote = origin
merge = refs/heads/test
'注意':如果checkout出来的是master分支,则
[branch "master"]
remote = origin
merge = refs/heads/master
高版本的Eclipse默认会配置好 Repository Settings部分
Eclipse Git操作
提交代码到本地服务器:
选中项目 ,Team> commit
提交代码到远程仓库
Team > remote > push
单击 AddSpec后,Specifications for push下面会出现 一条记录,
记住不要勾选 Force update
后面就直接 next, 再 finish就行了
git 切换分支,
Team > Switch to > 分支名称
从远程获仓库获取最新的代码到本地
Team > pull
git解决冲突:
代码在提交到远程仓库之前,先Team> pull 获取最新代码,
此处Test.java提示冲突,
右击Test.java ,单击merge tool
合并、处理代码后,
右击 Test.java, 单击 Add to Git Index
再Commit And Push