Are .gitignore files from directories above the repository's or from home directory loaded in any versions of Git?

Mika Feiler

Are .gitignore files from directories above the repository's or from home directory (~/.gitignore) loaded in any versions of Git?

~/.gitignore is mentioned by some advisory web postings despite not working in the version of Git on my system, and my system manual is unclear about how far up Git will walk looking for a .gitignore, although only mentions $XDG_CONFIG_HOME/git/ignore as a home directory global gitignore file location.

My problem stems from, to manage my home directory dotfiles i have presently chosen to use Git with a custom GIT_DIR environment variable setting, which does fine with not having Git default to that repository in any subdirectories of my ~.

But, as .gitignore is hardcoded and can't be selected by an environment variable (which i would like to be like "${GIT_DIR%/}ignore"), being afraid that on some of my systems ~/.gitignore could end up applying either globally or in repositories in the subdirectories of ~, i resorted to adding the below snippet to my ${GIT_DIR}/info/exclude and then staging the ${GIT_DIR}/info/exclude file into the repository, keeping all my gitignore entries that are to apply to my dotfiles management repository in there (and in .gitignore files in dotfiles-only subdirectories). What i don't like about it is that it's pretty dirty and it might cause minor problems sometimes.

The snippet mentioned above, with .gd being my $GIT_DIR:

/.gd/**
!/.gd/info/
!/.gd/info/exclude
user1686

The global ignore path is configurable (through the 'core.excludesFile' option), and until git version 1.7.12 it actually didn't have $XDG_CONFIG_HOME/git/ignore as the default value – the option used to be blank by default.

Therefore many people used to manually configure git to load ~/.gitignore as the global ignore file. Most likely everyone preferred this path due to its proximity to the ~/.gitconfig file (which is where global settings were kept pre-1.7.12).

However, this only happens to use the same filename, but otherwise is completely unrelated to the per-repository .gitignore search which always stops at worktree root.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

any way to obtain the "dot git" (.git) directory from a github repository?

From Dev

Proper way to checkout home directory .rc files from a git repo?

From Dev

Why do all files and directories from my home directory appear in Desktop?

From Dev

Git (SourceTree): gitignore already tracked files without deleting from online repository

From Dev

Copying files from home directory to computer directory

From Dev

Git how to ignore files in .gitignore from checkout

From Dev

copy files from a directory to multiple directories

From Java

Remove directory from remote repository after adding them to .gitignore

From Dev

Access files in Home directory from live mode

From Java

How to remove a directory from git repository?

From Dev

Can not clone any git repository from github

From Dev

How to clone only some directories from a git repository?

From Dev

How to clone only some directories from a git repository?

From Dev

Can I create a Git repository from 2 disconnected directories?

From Dev

How to batch delete files/directories from svn repository

From Dev

How to batch delete files/directories from svn repository

From Dev

Removing a directory from .gitignore so git starts to track changes in it

From Dev

fatal: Not a git repository (or any of the parent directories): .git (And yet the repository exists)

From Dev

Remove .pyc files from Git remote repository

From Dev

Remove files from a bare Git Repository Globally

From Dev

How to download files from git repository?

From Dev

How to extract the source files from a git repository?

From Dev

Remove files from a bare Git Repository Globally

From Dev

Move Files From Root Directory to another users Home Directory

From Dev

Recreate a git repository from a server stored .git directory

From Dev

Move only files recursively from multiple directories into one directory with mv

From Dev

Copy files from multiple directories into one directory using Python

From Dev

Copy multiple files from one directory to multiple other directories

From Dev

copy files from multiple sub-directories to the same destination directory

Related Related

  1. 1

    any way to obtain the "dot git" (.git) directory from a github repository?

  2. 2

    Proper way to checkout home directory .rc files from a git repo?

  3. 3

    Why do all files and directories from my home directory appear in Desktop?

  4. 4

    Git (SourceTree): gitignore already tracked files without deleting from online repository

  5. 5

    Copying files from home directory to computer directory

  6. 6

    Git how to ignore files in .gitignore from checkout

  7. 7

    copy files from a directory to multiple directories

  8. 8

    Remove directory from remote repository after adding them to .gitignore

  9. 9

    Access files in Home directory from live mode

  10. 10

    How to remove a directory from git repository?

  11. 11

    Can not clone any git repository from github

  12. 12

    How to clone only some directories from a git repository?

  13. 13

    How to clone only some directories from a git repository?

  14. 14

    Can I create a Git repository from 2 disconnected directories?

  15. 15

    How to batch delete files/directories from svn repository

  16. 16

    How to batch delete files/directories from svn repository

  17. 17

    Removing a directory from .gitignore so git starts to track changes in it

  18. 18

    fatal: Not a git repository (or any of the parent directories): .git (And yet the repository exists)

  19. 19

    Remove .pyc files from Git remote repository

  20. 20

    Remove files from a bare Git Repository Globally

  21. 21

    How to download files from git repository?

  22. 22

    How to extract the source files from a git repository?

  23. 23

    Remove files from a bare Git Repository Globally

  24. 24

    Move Files From Root Directory to another users Home Directory

  25. 25

    Recreate a git repository from a server stored .git directory

  26. 26

    Move only files recursively from multiple directories into one directory with mv

  27. 27

    Copy files from multiple directories into one directory using Python

  28. 28

    Copy multiple files from one directory to multiple other directories

  29. 29

    copy files from multiple sub-directories to the same destination directory

HotTag

Archive