问题描述:在创建完项目上传至GitHub过程中,配置的.gitignore文件未生效
问题解决
#停止跟踪所有文件 但非删除
huadembp:alive huayu$ git rm -r --cached .
rm '.DS_Store'
rm '.gitignore'
rm '.idea/.gitignore'
rm '.idea/compiler.xml'
rm '.idea/misc.xml'
rm '.idea/modules.xml'
rm '.idea/vcs.xml'
rm 'README.md'
rm 'alive-server/.DS_Store'
rm 'alive-server/alive-server.iml'
rm 'alive-server/pom.xml'
rm 'alive-server/src/.DS_Store'
rm 'alive-server/src/main/java/com/example/alive/common/response/Test.java'
rm 'alive-server/src/main/java/com/example/alive/common/tool/Test.java'
rm 'alive-server/src/main/java/com/example/alive/controller/test/TestController.java'
rm 'alive-server/src/main/java/com/example/alive/entity/dto/Test.java'
rm 'alive-server/src/main/java/com/example/alive/entity/vo/Test.java'
rm 'alive-server/src/main/java/com/example/alive/mapper/Test.java'
rm 'alive-server/src/main/java/com/example/alive/service/Test.java'
rm 'alive-server/src/main/resources/mapper/TestMapper.xml'
rm 'alive.iml'
rm 'pom.xml'
#重新提交
huadembp:alive huayu$ git add .
huadembp:alive huayu$ git commit -m "update .gitignore"
[develop 203069f] update .gitignore
7 files changed, 69 deletions(-)
delete mode 100644 .idea/.gitignore
delete mode 100644 .idea/compiler.xml
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
delete mode 100644 .idea/vcs.xml
delete mode 100644 alive-server/alive-server.iml
delete mode 100644 alive.iml
huadembp:alive huayu$ git push
枚举对象: 5, 完成.
对象计数中: 100% (5/5), 完成.
使用 8 个线程进行压缩
压缩对象中: 100% (3/3), 完成.
写入对象中: 100% (3/3), 284 字节 | 284.00 KiB/s, 完成.
总共 3 (差异 2),复用 0 (差异 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/Myuhua/alive.git
50fb58e..203069f develop -> develop
删除缓存后重新提交,这时候就会发现被忽略的文件变浅黄(即被忽略提交)。