git忽略特定文件或目录

来源:互联网 发布:北邮ipv6网络电视 编辑:程序博客网 时间:2024/04/29 23:21

在将某个目录添加到git版本库、或提交某个git版本库的改动时,可能希望忽略掉一些文件或目录(如编译时生成的.o、.a文件等),可以修改.git/info/exclude文件来实现。

举例如下:

vi .git/info/exclude


# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
*.[oa]        #忽略以.o或.a结尾的文件或目录
*.pyc        
*.exe       #忽略以.exe结尾的文件或目录
.*              #忽略以.开头的文件或目录
*.rar
*.zip
*.gz
*.bz2
*.db
*.sqlite