(1)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;
如下图

确定后在提交代码就会自动屏蔽掉这些文件。
(2)IntelliJ IDEA中用git提交新项目的代码(配置git关联)
(3)idea的maven依赖爆红的解决方法

检查下面的配置
上边一致之后,重新更新maven即可,实在不行清一下缓存试试

(4)通过git回滚到某个提交节点或某个版本
1.项目右键后,点击“Git - Show History

2.这里会显示有历史提交的版本记录(这里我们假设要回滚到 “提交” 版本中)
3.选中 “提交” ,右键Copy Revision Number

4.回到项目,右键-Git-Repository-Reset HEAD

5.Reset Type选择Hard,To Commit处黏贴刚刚复制的版本号;然后点击Reset按钮

以上操作就能够使得项目回滚到“提交”版本
(注:操作之后提交版本会进行报错)
(1)、点击IDEA右下角,输入“ git push -u origin master -f “这个代码是表示冲突的时候强制提交,一般不建议
如果出现以下代码,说明在代码平台上这个分支是受保护的,不允许提交,可以在代码平台上把分支先设置成不保护状态
1
|
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
|
出现以下内容表示提交成功
1
2
3
4
5
6
7
8
9
|
Enumerating objects: 49, done.
Counting objects: 100% (49/49), done.
Delta compression using up to 8 threads
Compressing objects: 100% (26/26), done.
Writing objects: 100% (32/32), 139.99 KiB | 46.66 MiB/s, done.
Total 32 (delta 7), reused 18 (delta 2)
To 提交地址
+ 0304112...e40991a master -> master (forced update)
Branch 'master' set up to track remote branch 'master' from 'origin'.
|
(5)maven引用本地jar包

在找到报错的依赖,手动添加jar进去即可

(6)统一设置字符编码
(7)注解生效激活
(8)File Type过滤
(9)Maven中跳过单元测试,减少声明周期
(10)git 撤回commit(已提交未push)方法
1.版本控制,打开log,查看提交记录

2.选中要撤回的版本,右键,‘undo commit’
(11)intellij idea 中右键项目没有git,无法使用idea提交代码拉代码啥的
解决:打开setting,ctrl + alt +s 打开VersionControl添加git仓库,添加后再次右键项目查看,GIT就出现了
(11)idea自定义代码格式导入
选择Setting =>Plugins=>Browse repositories,搜索Eclipse即可出现,点击左上角的Download and Install安装。安装之后重启Intellij,即可在Setting =>Eclipse Code Formatter找到配置项。