1. 程式人生 > >Git 本地提交時,忽略特定檔案或目錄

Git 本地提交時,忽略特定檔案或目錄

https://blog.csdn.net/huzhenwei/article/details/7426093

在將某個目錄新增到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