创建 .gitignore 随意设置想跟踪哪些文件 和不跟踪哪些文件.
1.在项目根目录下建立 .gitignore 文件
2. .gitignore文件过滤有两种模式,开放模式和保守模式
2.1开放模式负责设置过滤哪些文件和文件夹
eg:
过滤文件夹设置:
/mtk/ 表示过滤这个文件夹
过滤文件设置
指定过滤某种类型的文件:
*.zip
*.rar
*.via
*.tmp
*.err
指定过滤某个文件:
/mtk/do.c
/mtk/if.h
2.2 b保守模式负责设置哪些文件不被过滤,也就是哪些文件要被跟踪。
跟踪某个文件夹
!/plutommi/mmi
跟踪某类文件
!*.c
!*.h
跟踪某个指定文件
!/plutommi/mmi/mmi_features.h
3.配置.gitignore 的简易原则
采用共享模式与保守模式结合配置的办法。eg:一个文件夹下有很多文件夹和文件,而我只想跟踪其中的一个文件,这样设置就可以满足这种情况,先用共享模式把整个目录 都设置为不跟踪,然后再用保守模式把这个文件夹中想要跟踪的文件设置为被跟踪,配置很简单,就可以跟踪想要跟踪的文件。
4.我做mtk项目用到的 .gitignore 文件的具体配置如下:
#######开放模式###########################
# folder #
###############
/_souceInsight_/
/build/
/MoDIS/
/Doc/
/mtk_lib/
/scripts/
/header_temp/
/tools/AudioResGen/
/tools/GLBOptionSwtichRef/
/tools/GMSL/
/tools/MinGW/
/tools/MSYS/
/tools/NewMMIResourceTool/
/tools/NVRAMStatistic/
/tst/
/verno/
/plutommi/tool/
/plutommi/Customer/ResGenerator/
/plutommi/Customer/CustResource/
/plutommi/Customer/LcdResource/
/plutommi/Customer/Images/
/plutommi/mmi/Framework/EventHandling/EventsInc/mmi_menu_handlers.h
/vendor/font/MTK/official/project/plutommi/content/inc/
/vendor/font/MTK/official/project/plutommi/content/src/
###############
# fixed file #
###############
.gitignore
*.exe
*.txt
*.def
*.dsp
*.lib
*.doc
*.dll
*.lnt
*.pm
*.xls
*.dbg
*.DBG
*.o
*.plg
*.keep
###############
# temp file #
###############
~*
*.log
*.cmm
*.men
*.ini
*.fig
*.cmp
*.tmp
###############
# script #
###############
*.bat
#########保守模式############
!/plutommi/Customer/CustResource/PLUTO_MMI/
!/plutommi/Customer/LcdResource/MainLcd128X160/
!/plutommi/Customer/Images/PLUTO128X160/image.zip
!/vendor/font/MTK/official/project/plutommi/content/inc/MainLcd128X160/
!/vendor/font/MTK/official/project/plutommi/content/src/MainLcd128X160/
===
*.obj
*.pch
*.res
*.idb
*.dep
*.sbr
*.suo
*.pdb
*.ncb
*.plg
*.ilk
*.o
*.lo
*.la
*.al
.libs
*.so
*.so.[0-9]*
*.a
*.pyc
*.pyo
*.rej
*~
#*#
.#*
.*.swp
.DS_Store
/Debug/
/ImgCache/
/Backup_rar/
/Debug/
/debug/
*.orig
*.aps
*.APS
*.chm
*.exp
*.pdb
*.rar
*.gitignore
*.pch
*.res
*.idb
*.dep
*.sbr
*.suo
*.pdb
*.ncb
*.plg
*.ilk
*.o
*.lo
*.la
*.al
.libs
*.so
*.so.[0-9]*
*.a
*.pyc
*.pyo
*.rej
*~
#*#
.#*
.*.swp
.DS_Store
/Debug/
/ImgCache/
/Backup_rar/
/Debug/
/debug/
*.orig
*.aps
*.APS
*.chm
*.exp
*.pdb
*.rar
*.gitignore