When using Git as a version control tool, .gitignore
files are used to specify files and directories to be ignored to avoid them being accidentally uploaded to the code repository. In the UniApp project, we can also create a .gitignore
file to define files and directories that need to be ignored. The following is an example of the file content of a complete UniApp project .gitignore
:
# 忽略以下文件和目录
node_modules/
/dist/
/dev/
/.DS_Store
# 忽略UniApp编译生成的小程序相关目录
/unpackage/
# 忽略本地配置文件(请根据实际情况修改)
/manifest.local.json
# 忽略编辑器自动生成的文件
.idea/
.vscode/
# 忽略日志文件
/logs/
# 忽略临时文件
/temp/
# 忽略构建工具自动生成的文件
/build/
# 忽略npm安装的包文件
/package-lock.json
/yarn.lock
# 忽略个人配置文件(请根据实际情况修改)
.env.local
.env.development.local
.env.production.local
The above example .gitignore
files cover files and directories that need to be ignored in common UniApp projects. You can make appropriate adjustments and add other files or directories that need to be ignored based on your project needs.
Make sure .gitignore
the files are located in the root directory of the project and are versioned through a Git management tool to ensure that ignored files and directories are not committed to the code base. This reduces the size of the code base and improves collaboration efficiency.