Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_ignore [2018/05/24 09:33] – [Overview] rpjday | git_ignore [2019/02/22 18:18] (current) – [Debugging gitignore files] rpjday | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Overview ===== | ===== Overview ===== | ||
| - | How to identify untracked files that Git should intentionally ignore; files already tracked by Git are not affected. | + | How to identify untracked files that Git should intentionally ignore |
| Some links: | Some links: | ||
| * [[https:// | * [[https:// | ||
| + | * [[https:// | ||
| - | ===== Four levels of ignoring files ===== | + | ===== Introductory .gitignore ===== |
| + | |||
| + | ==== Basic .gitignore file ==== | ||
| + | |||
| + | Excerpts from the Linux kernel source top-level '' | ||
| + | |||
| + | < | ||
| + | .* [all hidden files/ | ||
| + | *.a | ||
| + | *.asn1.[ch] | ||
| + | *.bz2 | ||
| + | *.c.[012]*.* | ||
| + | *.dt.yaml | ||
| + | *.dtb | ||
| + | *.dtb.S | ||
| + | *.dwo | ||
| + | *.elf | ||
| + | *.gz | ||
| + | *.ko | ||
| + | ... | ||
| + | Module.symvers | ||
| + | ... | ||
| + | # | ||
| + | # Top-level generic files | ||
| + | # | ||
| + | /tags | ||
| + | /TAGS | ||
| + | /linux | ||
| + | /vmlinux | ||
| + | / | ||
| + | / | ||
| + | ... | ||
| + | / | ||
| + | ... | ||
| + | # | ||
| + | # Exceptions: git files that we don't want to ignore even if they are dot-files | ||
| + | # | ||
| + | !.gitignore | ||
| + | !.mailmap | ||
| + | !.cocciconfig | ||
| + | !.clang-format | ||
| + | ... | ||
| + | # | ||
| + | # Generated include files | ||
| + | # | ||
| + | include/ | ||
| + | include/ | ||
| + | include/ | ||
| + | arch/ | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | ==== Recursive .gitignore ==== | ||
| + | |||
| + | Subdirectories can have more specific '' | ||
| + | |||
| + | < | ||
| + | # | ||
| + | # Generated files | ||
| + | # | ||
| + | bin2c | ||
| + | conmakehash | ||
| + | kallsyms | ||
| + | pnmtologo | ||
| + | unifdef | ||
| + | recordmcount | ||
| + | sortextable | ||
| + | asn1_compiler | ||
| + | extract-cert | ||
| + | sign-file | ||
| + | insert-sys-cert | ||
| + | </ | ||
| + | |||
| + | The Linux kernel source repo has over 200 '' | ||
| + | ===== Advanced ignoring ===== | ||
| + | |||
| + | ==== Four levels of ignoring files ==== | ||
| Each line in a gitignore/ | Each line in a gitignore/ | ||
| - | * Patterns read from the command line for those commands that support them, | + | * Patterns read from the command line for those commands that support them (see '' |
| * Patterns read from a '' | * Patterns read from a '' | ||
| * Patterns read from (repository-specific) '' | * Patterns read from (repository-specific) '' | ||
| * Patterns read from the file specified by the configuration variable '' | * Patterns read from the file specified by the configuration variable '' | ||
| - | Rationale for different levels of gitignore files: | + | ==== Rationale for different levels of gitignore files ==== |
| * 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 '' | * 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 '' | ||
| - | * Patterns which are both specific to a particular repository //and// specific to an individual user’s workflow should go into the '' | + | * Patterns which are both specific to a particular repository //and// specific to an individual user’s workflow should go into the '' |
| - | * 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 '' | + | * 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 '' |
| - | For debugging gitignore/exclude | + | < |
| + | $ git config --global core.excludesfile ~/.my_ignorefile | ||
| + | </ | ||
| + | |||
| + | ==== Debugging gitignore | ||
| < | < | ||
| $ man git-check-ignore | $ man git-check-ignore | ||
| </ | </ | ||
| + | |||
| + | ===== gitignore gotchas ===== | ||
| + | |||
| + | * Since '' | ||