IntelliJ IDEA提交git到码云(摘抄网上两篇内容,合
IntelliJ IDEA中用git提交代码时忽略文件的设置
在用intellijidea开发时,经常会用git或其他版本管理工具提交代码到远程。
但是idea默认会把所有只要本地与远程不同的文件都会列出来,
实际上像后缀名是.iml, .idea这类文件是不需要提交的。
如下图所示

如果每次都手动取消这些文件,都是些重复性的操作。
按如下操作可一次性设置好,以后提交代码就会自动忽略这些文件: .iml, .idea,target 文件夹
1.进入idea设置界面
Windows环境:File - Settings - Editor - File Types
Mac环境:Preferences.. - Editor - File Types
2.在下面的ignore files and folders 框里加入 *.iml;.idea;target;
如下图

确定后在提交代码就会自动屏蔽掉这些文件。
IDEA教程之Gitee插件(码云)
安装Gitee插件
【File】-【Settings】-【Plugins】,查看gitee插件并安装

安装完成后,重启IDEA

添加Gitee账户
【File】-【Settings】-【Version Control】-【Gitee】,点击【Add account】添加账户

输入账号和密码,点击【Log In】

登录成功后会显示账户信息

项目初始化
IDEA项目分享至Gitee
选中要同步的项目,点击菜单【VCS】-【Import into Version Control】-【Share Project on Gitee】

点击【Share】按钮

将不必要的文件去除对勾,点击【Add】

提示项目成功分享至Gitee

登录Gitee可看到项目

Gitee项目克隆至IDEA
【VCS】-【Checkout from Version Control】-【Git】

输入Gitee项目的URL,点击【Clone】,开始克隆

点击【Yes】

点击【This Window】

克隆成功,可看到项目代码

Gitee团队协作
拉取代码
【VCS】-【Update Project】

点击【OK】

提示更新多少个文件,可以点击【View】查看更新的文件列表

更新文件列表

更新文件列表
提交代码
注:提交代码前,应先拉取。若拉取时出现代码冲突,应先解决冲突后再提交
【VCS】-【Commit】

可选择哪些代码提交,默认全选,输入提交信息,点击【Commit and Push】。或者先点击【Commit】,再从菜单中点击【Push】

选择默认分支,点击【Push】

提交成功

代码冲突
当在提交或拉取代码时,出现冲突会弹出如下对话框,选中冲突的文件,点击【Merge】

对话框中出现三个框,分别为:
左边框为本地待提交的代码
右边框为Gitee中代码
中间框为解决冲突后的结果代码
解决代码冲突:我们修改中间的代码,可根据情况选择【Accept Left】或【Accept Right】;亦或者手动修改冲突代码后点击【Apply】

点击【Yes】

当所有冲突文件解决后,重新提交即可