diff --git a/README.md b/README.md index aba2a74..bbfa08d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1472 TILs and counting..._ +_1473 TILs and counting..._ --- @@ -326,6 +326,7 @@ _1472 TILs and counting..._ - [List Untracked Files](git/list-untracked-files.md) - [List Untracked Files For Scripting](git/list-untracked-files-for-scripting.md) - [Move The Latest Commit To A New Branch](git/move-the-latest-commit-to-a-new-branch.md) +- [Override The Global Git Ignore File](git/override-the-global-git-ignore-file.md) - [Pick Specific Changes To Stash](git/pick-specific-changes-to-stash.md) - [Pulling In Changes During An Interactive Rebase](git/pulling-in-changes-during-an-interactive-rebase.md) - [Push To A Branch On Another Remote](git/push-to-a-branch-on-another-remote.md) diff --git a/git/override-the-global-git-ignore-file.md b/git/override-the-global-git-ignore-file.md new file mode 100644 index 0000000..f0a1c69 --- /dev/null +++ b/git/override-the-global-git-ignore-file.md @@ -0,0 +1,33 @@ +# Override The Global Git Ignore File + +One of the places that `git` looks when deciding whether to pay attention to or +ignore a file is in your global _ignore_ file. By default, `git` will look for +this file at `$XDG_CONFIG_HOME/git/ignore` or `$HOME/.config/git/ignore`. + +I don't have `$XDG_CONFIG_HOME` set on my machine, so it will fall back to the +config directory under `$HOME`. + +I may have to create the `git` directory and `ignore` file. + +```bash +$ mkdir $HOME/.config/git +$ touch $HOME/.config/git/ignore +``` + +Then I can add file and directories to exclude to that `ignore` file just like +I would any other `.gitignore` file. + +If I'd prefer for the global _ignore_ file to live somewhere else, I can +specify that location and filename in my `$HOME/.gitconfig` file. + +``` +[core] + excludesFile = ~/.gitignore +``` + +Setting this will override the default, meaning the default file mentioned +above will be ignored ("now you know how it feels, ignore file!"). In this +case, I'll need to create the `.gitignore` file in my home directory and add +any of my ignore rules. + +[source](https://git-scm.com/docs/gitignore)