为Git添加忽略文件

用Eclipse PDT开发PHP时,Eclipse会自动创建几个系统文件。这些文件在Git提交时可以忽略。

使用git status可以看到这些文件(.project, .buildpath和.settings):

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    .buildpath
#    .project
#    .settings/
#    includes/
#    index.php
nothing added to commit but untracked files present (use "git add" to track)

怎么忽略呢?方法是创建.gitignore文件,将需要略过的文件名和目录名添加到.gitignore:

$ cat .gitignore 
.project
.buildpath
.settings

再用git status查看,就看不到这几个文件了:

$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    .gitignore
#    includes/
#    index.php
nothing added to commit but untracked files present (use "git add" to track)
原文地址:https://www.cnblogs.com/eastson/p/2688259.html