.gitignore

场景

开发工具IDE为IntelliJ IDEA,IDEA提项目至本地仓库会提.idea文件夹内容。其中是一些项目配置信息,含历史记录、版本控制等。这些内容可不上传git。此时需编.gitignore文件忽略无需提交文件。IDEA插件.ignore可做该事。

安装

  • File->Settings
  • 左侧菜单找Plugins,点Browse repositories…
  • 如图搜.ignore,点Install,装完重启IDEA即可

注意

按上法装完重启IDEA或报错。报错下载压缩包,选Install plugin from disk并重启IDEA即可。

使用

  • 项目右键->New ->.ignore file ->.gitignore file(Git)
  • 先选Example user template,以后可手添需过滤文件,最后点Generate生成。然后发现被忽略文件名变灰,此时可提代码;
  • 也可右键加文件到忽略名单。

规则

*.a       # 忽略所有.a结尾的文件
!lib.a    # 但lib.a除外
/TODO     # 仅仅忽略项目根目录下的TODO文件,不包括subdir/TODO
build/    # 忽略build/目录下的所有文件
doc/*.txt # 会忽略doc/notes.txt但不包括doc/server/arch.txt

模板

# Built application files
*.apk
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

# Signing configuration file (storePassword, etc)
keystore.properties

注意

  • .gitignore只忽略原没被track文件,某些文件已被纳入版本管理则改.gitignore无效。可先删本地缓存(变未track状)后再提。
    git rm -r –cached filePath 
    git commit -m "remove xx"
    
    git rm -r –cached . 
    git add . 
    git commit -m "update .gitignore"
    
  • 参数-r删文件夹及其子目录,–cached删暂存区文件而不删工作区文件。第一种删某文件,第二种删所有暂存区文件,再加一遍,等同更新一遍。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

snpmyn

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

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

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

打赏作者

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

抵扣说明:

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

余额充值