GITIGNORE(5) Git Manual GITIGNORE(5) (NAME) gitignore - (SYNOPSIS) $XDG_CONFIG_HOME/git/ignore, $GIT_COMMON_DIR/info/exclude, .gitignore (DESCRIPTION) gitignore . (NOTES) . gitignore . gitignore ( ): o . o .gitignore ( ) . .gitignore . .gitignore . o $GIT_COMMON_DIR/info/exclude. o core.excludesFile. . o ( ) .gitignore . o ( ) $GIT_COMMON_DIR/info/exclude . o ( ) core.excludesFile ~/.gitconfig . $XDG_CONFIG_HOME/git/ignore . $XDG_CONFIG_HOME $HOME/.config/git/ignore . git ls-files git read-tree gitignore . git status git add . (PATTERN FORMAT) o . o # . ("\") . o ("\") . o "!" () . . . "!" ("\") : "\!important!.txt". o "/" . .gitignore . o ( ) .gitignore . .gitignore . o $GIT_COMMON_DIR/info/exclude core.excludesFile "/" . o . o doc/frotz/ doc/frotz a/doc/frotz frotz/ frotz a/frotz ( .gitignore ). o "*" . "?" "/" . [a-zA-Z] . fnmatch(3) FNM_PATHNAME . o ("\") "\*" ( "\a" "a" ). fnmatch(3) . ("**") : o "**" . "**/foo" "foo" "foo". "**/foo/bar" "bar" "foo" . o "/**" . "abc/**" "abc" .gitignore . o . "a/**/b" "a/b" "a/x/b" "a/x/y/b" . o . (CONFIGURATION) core.excludesFile $GIT_COMMON_DIR/info/exclude. exclude $GIT_COMMON_DIR/info/exclude . (NOTES) gitignore . git rm --cached . .gitignore . .gitignore . . (EXAMPLES) o hello.* hello. . /hello.* hello.txt hello.c a/hello.java . o foo/ foo foo ( pathspec ) o doc/frotz /doc/frotz .gitignore . . o foo/* foo/test.json ( ) foo/bar ( ) foo/bar/hello.c ( ) bar/hello.c . $ git status [...] # Untracked files: [...] # Documentation/foo.html # Documentation/gitignore.html # file.o # lib.a # src/internal.o [...] $ cat .git/info/exclude # ignore objects and archives, anywhere in the tree. *.[oa] $ cat Documentation/.gitignore # ignore generated html files, *.html # except foo.html which is maintained by hand !foo.html $ git status [...] # Untracked files: [...] # Documentation/foo.html [...] : $ cat .gitignore vmlinux* $ ls arch/foo/kernel/vm* arch/foo/kernel/vmlinux.lds.S $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore .gitignore arch/foo/kernel/vmlinux.lds.S . foo/bar ( /* - foo/bar ): $ cat .gitignore # exclude everything except directory foo/bar /* !/foo /foo/* !/foo/bar (SEE ALSO) git-rm(1), gitrepository-layout(5), git-check-ignore(1) (GIT) git(1) Git 2.55.0 2026-06-29 GITIGNORE(5)