{"id":4406,"date":"2026-06-25T11:10:49","date_gmt":"2026-06-25T09:10:49","guid":{"rendered":"https:\/\/nguenkam.com\/blog\/?p=4406"},"modified":"2026-06-25T11:10:49","modified_gmt":"2026-06-25T09:10:49","slug":"the-3-ways-to-ignore-files-in-git","status":"publish","type":"post","link":"https:\/\/nguenkam.com\/blog\/index.php\/2026\/06\/25\/the-3-ways-to-ignore-files-in-git\/","title":{"rendered":"The 3 Ways to Ignore Files in Git"},"content":{"rendered":"\n<p>You probably know <code>.gitignore<\/code> \u2014 but Git actually gives us <strong>3 different levels<\/strong> of file exclusion. Each one has its own purpose. Let&#8217;s explore them all, simply.<\/p>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">Why Ignore Files?<\/span><\/h4>\n\n\n\n<p>Some files should <strong>never<\/strong> be pushed to your remote repository. Here are the most common ones:<\/p>\n\n\n\n<ul><li><strong>Passwords &amp; API keys<\/strong>\u00a0\u2014\u00a0<code>.env<\/code>,\u00a0<code>config_secret.json<\/code><\/li><li><strong>Auto-generated folders<\/strong>\u00a0\u2014\u00a0<code>node_modules\/<\/code>,\u00a0<code>__pycache__\/<\/code><\/li><li><strong>Personal notes<\/strong>\u00a0\u2014\u00a0<code>notes.txt<\/code>,\u00a0<code>todo.md<\/code><\/li><li><strong>OS system files<\/strong>\u00a0\u2014\u00a0<code>.DS_Store<\/code>\u00a0(Mac),\u00a0<code>Thumbs.db<\/code>\u00a0(Windows)<\/li><\/ul>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">Method 1 \u2014\u00a0<code>.gitignore<\/code>\u00a0(The Classic, Shared with Your Team)<\/span><\/h4>\n\n\n\n<p><em><strong>\u00a0Where is it? <\/strong> <\/em>At the <strong>root of our project<\/strong>, right next to your code:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignleft size-large\"><img loading=\"lazy\" width=\"438\" height=\"138\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image.png\" alt=\"\" class=\"wp-image-4408\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image.png 438w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-300x95.png 300w\" sizes=\"(max-width: 438px) 100vw, 438px\" \/><\/figure><\/div>\n\n\n\n<p><strong>\u00a0<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><em>How to see it?<\/em><\/strong>  It&#8217;s a hidden file (starts with a dot):<\/p>\n\n\n\n<ul><li><strong>Mac\/Linux<\/strong>: run&nbsp;<code>ls -la<\/code>&nbsp;in your terminal<\/li><li><strong>Windows<\/strong>: enable &#8220;Show hidden files&#8221; in File Explorer<\/li><li><strong>VS Code<\/strong>: it shows up directly in the file explorer<\/li><\/ul>\n\n\n\n<p><strong><em>How to use it?<\/em><\/strong>  Open <code>.gitignore<\/code> and add the files or folders you want to ignore:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Ignore the node_modules folder\r\nnode_modules\/\r\n\r\n# Ignore environment files (passwords, API keys)\r\n.env\r\n\r\n# Ignore all log files\r\n*.log\r\n\r\n# Ignore a specific file\r\nconfig_secret.json<\/code><\/pre>\n\n\n\n<p><strong><em>When to use it?<\/em><\/strong>   For rules that <strong>the whole team<\/strong> should follow: <code>node_modules<\/code>, <code>.env<\/code>, build files, etc.<\/p>\n\n\n\n<p><em><strong><span class=\"has-inline-color has-luminous-vivid-orange-color\">PS:<\/span><\/strong> This file is <strong>pushed to the remote<\/strong>. Everyone on your team can see exactly what you&#8217;ve excluded.<\/em><\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">Method 2 \u2014\u00a0<code>.git\/info\/exclude<\/code>\u00a0(Local &amp; Secret, Per Project)<\/span><\/h4>\n\n\n\n<p><strong><em>\u00a0Where is it?<\/em><\/strong>  Inside the <strong>hidden <code>.git<\/code> folder<\/strong> of our project:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"506\" height=\"135\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-1.png\" alt=\"\" class=\"wp-image-4409\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-1.png 506w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-1-300x80.png 300w\" sizes=\"(max-width: 506px) 100vw, 506px\" \/><\/figure>\n\n\n\n<p><strong><em>How to access it?<\/em><\/strong>  From our terminal, at the root of our project:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Open with VS Code\r\ncode .git\/info\/exclude\r\n\r\n# Or edit with nano\r\nnano .git\/info\/exclude\r\n\r\n# Or just display it\r\ncat .git\/info\/exclude<\/code><\/pre>\n\n\n\n<p><strong><em>How to use it?<\/em><\/strong>  The syntax is <strong>exactly the same<\/strong> as <code>.gitignore<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># My personal notes on this project\r\nnotes.txt\r\n\r\n# My local config file\r\nconfig_local.json\r\n\r\n# My personal test folder\r\nmy-tests\/<\/code><\/pre>\n\n\n\n<p><strong><em>When to use it?<\/em><\/strong>  For <strong>personal files tied to a specific project<\/strong> that we don&#8217;t want to share with our team.<\/p>\n\n\n\n<p><strong>Real-world example:<\/strong> You created a <code>notes.txt<\/code> file to jot down ideas while working on a team project. You don&#8217;t want to push it, but you also don&#8217;t want to touch the shared <code>.gitignore<\/code> for something so personal ? <code>.git\/info\/exclude<\/code> is perfect!<\/p>\n\n\n\n<p><em><strong><span class=\"has-inline-color has-luminous-vivid-orange-color\">Key advantage<\/span><\/strong> :  This file is <strong>never pushed<\/strong>. Your team doesn&#8217;t know it exists. It&#8217;s completely invisible from the remote.<\/em><\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4><span class=\"has-inline-color has-vivid-cyan-blue-color\">Method 3 \u2014\u00a0<code>~\/.config\/git\/ignore<\/code>\u00a0(Global &amp; Secret, Across All Projects)<\/span><\/h4>\n\n\n\n<p><strong><em>Where is it?<\/em><\/strong>  In your <strong>home directory<\/strong>, not inside any specific project:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"492\" height=\"137\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-2.png\" alt=\"\" class=\"wp-image-4410\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-2.png 492w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-2-300x84.png 300w\" sizes=\"(max-width: 492px) 100vw, 492px\" \/><\/figure>\n\n\n\n<p><strong><em>How to access it?<\/em><\/strong>  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Open with VS Code\r\ncode ~\/.config\/git\/ignore\r\n\r\n# Create the file if it doesn't exist yet\r\nmkdir -p ~\/.config\/git\r\ntouch ~\/.config\/git\/ignore<\/code><\/pre>\n\n\n\n<p><strong><em>How to use it?<\/em><\/strong>  Add files you want to ignore <strong>in every single project<\/strong> on your machine:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># macOS system files\r\n.DS_Store\r\n\r\n# Windows system files\r\nThumbs.db\r\ndesktop.ini\r\n\r\n# Editor files\r\n.vscode\/\r\n.idea\/\r\n*.swp<\/code><\/pre>\n\n\n\n<p><strong><em>When to use it?<\/em><\/strong>  For files tied to <strong>your personal environment<\/strong> that show up in every project.<\/p>\n\n\n\n<p><strong>Real-world example:<\/strong> On macOS, every folder automatically generates a <code>.DS_Store<\/code> file. Instead of adding it to every project&#8217;s <code>.gitignore<\/code>, add it here <strong>once<\/strong> \u2014 and it&#8217;s ignored everywhere, forever.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"875\" height=\"266\" src=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-3.png\" alt=\"\" class=\"wp-image-4411\" srcset=\"https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-3.png 875w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-3-300x91.png 300w, https:\/\/nguenkam.com\/blog\/wp-content\/uploads\/2026\/06\/image-3-768x233.png 768w\" sizes=\"(max-width: 875px) 100vw, 875px\" \/><\/figure>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4>How to Check Why a File Is Being Ignored<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># Ignored by .gitignore\r\n$ git check-ignore -v .DS_Store\r\n.gitignore:3:.DS_Store          .DS_Store\r\n\r\n# Ignored by .git\/info\/exclude\r\n$ git check-ignore -v notes.txt\r\n.git\/info\/exclude:7:notes.txt   notes.txt\r\n\r\n# Ignored by the global file\r\n$ git check-ignore -v .DS_Store\r\n\/Users\/yourname\/.config\/git\/ignore:2:.DS_Store    .DS_Store<\/code><\/pre>\n\n\n\n<p><em>If the command returns <strong>no output<\/strong>, the file is not being ignored by anyone.<\/em><\/p>\n\n\n\n<div style=\"height:100px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4>Summary<\/h4>\n\n\n\n<ul><li><strong><code>.gitignore<\/code><\/strong>&nbsp;? for rules&nbsp;<strong>shared with your team<\/strong><\/li><li><strong><code>.git\/info\/exclude<\/code><\/strong>&nbsp;? for your&nbsp;<strong>personal files on a specific project<\/strong>, in total privacy<\/li><li><strong><code>~\/.config\/git\/ignore<\/code><\/strong>&nbsp;? for your&nbsp;<strong>personal files across all projects<\/strong>, set it once and forget it<\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You probably know .gitignore \u2014 but Git actually gives us 3 different levels of file exclusion. Each one has its own purpose. Let&#8217;s explore them all, simply. Why Ignore Files? Some files should never be pushed to your remote repository. Here are the most common ones: Passwords &amp; API keys\u00a0\u2014\u00a0.env,\u00a0config_secret.json Auto-generated folders\u00a0\u2014\u00a0node_modules\/,\u00a0__pycache__\/ Personal notes\u00a0\u2014\u00a0notes.txt,\u00a0todo.md OS [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[920,61,707,956,1139,1051],"_links":{"self":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/4406"}],"collection":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=4406"}],"version-history":[{"count":2,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/4406\/revisions"}],"predecessor-version":[{"id":4412,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/4406\/revisions\/4412"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media\/807"}],"wp:attachment":[{"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=4406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=4406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nguenkam.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=4406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}