From ec3ba0da0581125ae9e9f9f0b35b3645c8ae9ca2 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 22 Feb 2021 17:53:16 -0600 Subject: [PATCH] Add Ignore Files Specific To Your Workflow as a git til --- README.md | 3 +- git/ignore-files-specific-to-your-workflow.md | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 git/ignore-files-specific-to-your-workflow.md diff --git a/README.md b/README.md index 066e47e..fa7d413 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://tinyletter.com/jbranchaud). -_1058 TILs and counting..._ +_1059 TILs and counting..._ --- @@ -244,6 +244,7 @@ _1058 TILs and counting..._ - [Grep For A Pattern On Another Branch](git/grep-for-a-pattern-on-another-branch.md) - [Grep Over Commit Messages](git/grep-over-commit-messages.md) - [Ignore Changes To A Tracked File](git/ignore-changes-to-a-tracked-file.md) +- [Ignore Files Specific To Your Workflow](git/ignore-files-specific-to-your-workflow.md) - [Include A Message With Your Stashed Changes](git/include-a-message-with-your-stashed-changes.md) - [Include Or Exclude Remaining Patch Changes](git/include-or-exclude-remaining-patch-changes.md) - [Include Some Stats In Your Git Log](git/include-some-stats-in-your-git-log.md) diff --git a/git/ignore-files-specific-to-your-workflow.md b/git/ignore-files-specific-to-your-workflow.md new file mode 100644 index 0000000..d2ff63d --- /dev/null +++ b/git/ignore-files-specific-to-your-workflow.md @@ -0,0 +1,31 @@ +# Ignore Files Specific To Your Workflow + +_If you want to watch instead of read, I explore this in [Four Ways to Ignore +Files with Git](https://www.youtube.com/watch?v=ip06v7Wnfz0)._ + +The most common way to tell git to ignore files is to add them to a project's +`.gitignore` file. This file is kept under version control, so it is shared +with anyone who clones the project. + +What about ignoring files that shouldn't necessarily be recorded in the +project's `.gitignore`? + +For instance, let's say I create a `notes.md` file to write some project notes +to myself or keep track of a few todo items. This file is just for me. I don't +want it committed. Because this `notes.md` is an idiosyncrasy of my workflow, I +don't want to exclude it in the tracked `.gitignore` file. + +Instead, this file is a perfect candidate for the git repository's +`.git/info/exclude` file. Git treats entries in this file the same as it does +the `.gitignore` file. This file only exists on my machine and is not under +version control. + +``` +# .git/info/exclude +notes.md +``` + +Once I've added that line, `notes.md` will no longer show up as an untracked +file when I run `git status`. + +See `man gitignore` for more details.