gitignore

NAME

gitignore - Specifies intentionally untracked files to ignoregitignore - 意図的に追跡されていないファイルを無視するように指定する

SYNOPSIS概要

$XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore$ XDG_CONFIG_HOME / git / ignore、$ GIT_DIR / info / exclude、.gitignore

DESCRIPTION説明

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details.gitignoreファイルには、Gitは無視すべきで意図的に追跡されていないファイルを指定します。Gitによって既に追跡されているファイルは影響を受けません。詳細は下記の「注意事項」を参照してください。

Each line in a gitignore file specifies a pattern. When deciding whether to ignore a path, Git normally checks gitignore patterns from multiple sources, with the following order of precedence, from highest to lowest (within one level of precedence, the last matching pattern decides the outcome):gitignoreファイル内の各行はパターンを指定します。パスを無視するかどうかを決定するとき、Gitは通常gitignore、次の優先順位で、最高から最低の順で、複数のソースからのパターンをチェックします(1レベルの優先順位内で、最後に一致したパターンが結果を決定します)。

  • Patterns read from the command line for those commands that support them.それらをサポートするそれらのコマンドのためにコマンドラインからパターンを読みます。

  • Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. These patterns match relative to the location of the .gitignore file. A project normally includes such .gitignore files in its repository, containing patterns for files generated as part of the project build..gitignoreパスと同じディレクトリ内、または任意の親ディレクトリ内のファイルから読み取られたパターン。上位レベルのファイル内のパターン(ワークツリーの最上位レベルまで)は、下位レベルのファイル内のパターンによって上書きされます。ファイル。これらのパターンは.gitignoreファイルの場所を基準にして一致します。プロジェクトは通常.gitignoreそのようなファイルをリポジトリに含み、プロジェクトビルドの一部として生成されたファイルのパターンを含みます。

  • Patterns read from $GIT_DIR/info/exclude.から読み取るパターン$GIT_DIR/info/exclude

  • Patterns read from the file specified by the configuration variable core.excludesFile.構成変数で指定されたファイルから読み取られたパターンcore.excludesFile

Which file to place a pattern in depends on how the pattern is meant to be used.どのファイルにパターンを配置するかは、そのパターンがどのように使用されることになっているかによって異なります。

  • Patterns which should be version-controlled and distributed to other repositories via clone (i.e., files that all developers will want to ignore) should go into a .gitignore file.バージョン管理され、クローンを介して他のリポジトリに配布されるべきパターン(つまり、すべての開発者が無視したい.gitignoreファイル)は、ファイルに入れるべきです。

  • Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user’s workflow) should go into the $GIT_DIR/info/exclude file.特定のリポジトリに固有であるが他の関連するリポジトリと共有する必要がないパターン(例えば、リポジトリ内に存在するが1人のユーザのワークフローに固有の補助ファイル)は$GIT_DIR/info/excludeファイルに入れるべきです。

  • Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.ユーザーがGitにすべての状況で無視させたいパターン(例えば、選択したユーザーのエディターによって生成されたバックアップまたは一時ファイル)は、通常core.excludesFile、ユーザーによって指定されたファイルに入ります~/.gitconfig。デフォルト値は$ XDG_CONFIG_HOME / git / ignoreです。$ XDG_CONFIG_HOMEが設定されていないか空の場合は、代わりに$ HOME / .config / git / ignoreが使用されます。

The underlying Git plumbing tools, such as git ls-files and git read-tree, read gitignore patterns specified by command-line options, or from files specified by command-line options. Higher-level Git tools, such as git status and git add, use patterns from the sources specified above.git ls-filesgit read-treeなどの基本的なGit配管ツールは、gitignoreコマンドラインオプションで指定されたパターン、またはコマンドラインオプションで指定されたファイルから読み取ります。git statusgit addなどの高レベルのGitツールは、上記で指定されたソースからのパターンを使用します。

PATTERN FORMATパターンフォーマット

  • A blank line matches no files, so it can serve as a separator for readability.空白行はファイルと一致しないため、読みやすくするための区切り文字として使用できます。

  • A line starting with # serves as a comment. Put a backslash ("\") in front of the first hash for patterns that begin with a hash.#で始まる行はコメントとして機能します。\ハッシュで始まるパターンの場合は、最初のハッシュの前に円記号( " ")を付けます。

  • Trailing spaces are ignored unless they are quoted with backslash ("\").末尾のスペースは、バックスラッシュ( " \")で囲まれていない限り無視されます。

  • An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "\!important!.txt".!パターンを否定するオプションの接頭辞 " "。前のパターンで除外された一致ファイルはすべて再び含まれます。ファイルの親ディレクトリが除外されている場合、そのファイルを再インクルードすることはできません。Gitはパフォーマンス上の理由から除外されたディレクトリをリストしません。そのため、どこに定義されていても、含まれているファイル上のパターンは効果がありません。リテラル " "で始まるパターンの場合\は、最初の " !"の前に円記号( " ")を付けます。!\!important!.txt

  • If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in Git).パターンがスラッシュで終わっている場合は、以下の説明の目的で削除されますが、ディレクトリーとの一致のみが検出されます。言い換えれば、foo/ディレクトリfooとその下のパスには一致しますが、通常のファイルやシンボリックリンクにfooは一致しません(これは、Gitでのpathspecの一般的な動作方法と一致します)。

  • If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the .gitignore file (relative to the toplevel of the work tree if not from a .gitignore file).パターンにスラッシュ/が含まれていない場合、Gitはそれをシェルグロブパターンとして扱い、.gitignoreファイルの場所に対する相対パス(.gitignoreファイルからでない場合は作業ツリーのトップレベルに対する相対パス)との一致をチェックします。

  • Otherwise, Git treats the pattern as a shell glob: "*" matches anything except "/", "?" matches any one character except "/" and "[]" matches one character in a selected range. See fnmatch(3) and the FNM_PATHNAME flag for a more detailed description.そうしないと、Gitはシェルグロブなどパターンが扱います:「*」以外のものと一致した「/」、「?」以外の任意の1つの文字に一致します「/」と「[]」選択された範囲内の1つの文字に一致します。より詳細な説明はfnmatch(3)とFNM_PATHNAMEフラグを参照してください。

  • A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".先頭のスラッシュはパス名の先頭に一致します。たとえば、「/ *.c」は「cat-file.c」と一致しますが、「mozilla-sha1 / sha1.c」とは一致しません。

Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:**フルパス名と一致するパターン内の2つの連続したアスタリスク( " ")は、特別な意味を持つことがあります。

  • A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".先頭に " **"とそれに続くスラッシュはすべてのディレクトリで一致することを意味します。例えば、 " **/foo" fooはパターン " foo" と同じようにどこでもファイルやディレクトリにマッチします。 " **/foo/barディレクトリ " bar"の直下にあるファイルやディレクトリ" "にマッチしますfoo

  • A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.末尾の " /**"は内部のすべてに一致します。例えば、 " abc/**" abc.gitignoreファイルの位置を基準にしてディレクトリ " " 内のすべてのファイルにマッチします、深さは無限です。

  • A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.スラッシュの後に2つの連続したアスタリスクが続く場合、スラッシュはゼロ個以上のディレクトリに一致します。たとえば、 " a/**/b"は " a/b"、 " a/x/b"、 " a/x/y/b"などに一致します。

  • Other consecutive asterisks are considered regular asterisks and will match according to the previous rules.他の連続したアスタリスクは通常のアスタリスクと見なされ、前の規則に従って一致します。

NOTESノート

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.gitignoreファイルの目的は、Gitによって追跡されない特定のファイルが追跡されないままであることを確実にすることです。

To stop tracking a file that is currently tracked, use git rm --cached.現在追跡されているファイルの追跡を停止するには、git rm --cachedを使用します。

EXAMPLES

    $ 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
    [...]

Another example:もう一つの例:

    $ cat .gitignore
    vmlinux*
    $ ls arch/foo/kernel/vm*
    arch/foo/kernel/vmlinux.lds.S
    $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore

The second .gitignore prevents Git from ignoring arch/foo/kernel/vmlinux.lds.S.2番目の.gitignoreはGitが無視するのを防ぎますarch/foo/kernel/vmlinux.lds.S

Example to exclude everything except a specific directory foo/bar (note the /* - without the slash, the wildcard would also exclude everything within foo/bar):特定のディレクトリ以外のものをすべて除外する例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-rm [1]gitrepository-layout [5]git-check-ignore [1]

GIT

Part of the git[1] suite一部のgit [1]スイート

関連記事

スポンサーリンク

border-left-color 左ボーダーの色を指定する

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る