关于.gitignore_global的配置

git规则

.gitignore只能忽略那些原来没有被track的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的

如果在个人目录下,添加了.gitignore,则提交代码时优先匹配 ~/.gitignore_global 的规则,其次是项目根目录或者.git文件夹下的.gitignore规则

解决办法

在个人目录下vim ~/.gitignore_global  添加如下配置

 

# Compiled class file
*.class
*.o
*.so
*.dll
*.exe
*.pid

# Log file
logs/
*.log

# Package Files
*.jar
*.war
*.ear
*.sar
*.tar
*.tar.gz
*.zip
*.rar
*.7z
*.iso
*.dmg
*.rpm

# Eclipse project files
.classpath
.project
.settings/


# Intellij project files
*.iml
.idea/

# project
application-local.properties
build/

# Mobile Tools for Java
.mtj.tmp/

# BlueJ files
*.ctxt

# virtual machine crash logs
hs_err_pid*

# tmp
tmp/
temp/

#OS generated files
.DS_Store
.Spotlight-V100
.Trashes
Thumbs.db

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

## maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties

# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored)
!/.mvn/wrapper/maven-wrapper.jar

 

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

.gitignore文件 具体的规则一搜就有。我在使用GIT的过程中,明明写好了规则,但问题不起作用,每次还是重复提交,无法忍受。其实这个文件里的规则对已经追踪的文件是没有效果的。所以我们需要使用rm命令清除一下相关的缓存内容。这样文件将以未追踪的形式出现 然后再重新添加提交一下 .gitignore文件里的规则就可以起作用了

参考博客  https://www.cnblogs.com/sloong/p/5523244.html

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

东方狱兔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值