git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 1/4] gitfaq: files in .gitignore are tracked

From
Shourya Shukla <shouryashukla.oo@gmail.com>
Date
Apr 21, 2020, 13:12 UTC
Message-ID
<20200421131223.29337-2-shouryashukla.oo@gmail.com>
In-Reply-To
<20200421131223.29337-1-shouryashukla.oo@gmail.com>

Add issue in 'Common Issues' section which addresses the problem of Git tracking files/paths mentioned in '.gitignore'.

Signed-off-by: Shourya Shukla <shouryashukla.oo@gmail.com>
---
 Documentation/gitfaq.txt | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt
index 1cf83df118..96767e7c75 100644
--- a/Documentation/gitfaq.txt
+++ b/Documentation/gitfaq.txt
@@ -223,6 +223,27 @@ a file checked into the repository which is a template or set of defaults which
 can then be copied alongside and modified as appropriate.  This second, modified
 file is usually ignored to prevent accidentally committing it.
 
+[[files-in-.gitignore-are-tracked]]
+I asked Git to ignore various files, yet they are still tracked::
+	Git ignores files matching the patterns stated in the '.gitignore'.
+	Consequently, `git add` does not add the files/paths matching the
+	pattern in `.gitignore`, meaning they remain untracked; `git status`
+	does not list the aforementioned files/paths as untracked.
+
+	One thing to note is that the `.gitignore` mechanism applies only
+	to the files that are not already tracked. A file/path that is
+	already tracked will stay to be tracked even if you add a pattern
+	that happens to match it to `.gitignore` file.
+
+	This is probably the reason why Git shows some files/paths in the
+	staging area. These entities were being tracked before and later
+	were added in the `.gitignore`, due to which they show up in the
+	staging area.
+
+	To completely ignore and untrack files/paths falling in the above
+	category, it is advised to use `git rm --cached <file>` as well as
+	add these files/paths in the `.gitignore`.
+
 Hooks
 -----
 
-- 
2.20.1
Previous: Shourya ShuklaNext: Junio C Hamano
Message 2 of 15 in “gitfaq: add issues in the 'Common Issues' section”
  1. 0/4 gitfaq: add issues in the 'Common Issues' sectionShourya Shukla, Apr 21, 2020
  2. 1/4 gitfaq: files in .gitignore are trackedShourya Shukla, Apr 21, 2020
  3. Junio C HamanoApr 21, 2020
  4. 2/4 gitfaq: changing the remote of a repositoryShourya Shukla, Apr 21, 2020
  5. Junio C HamanoApr 21, 2020
  6. Shourya ShuklaApr 27, 2020
  7. 3/4 gitfaq: shallow cloning a repositoryShourya Shukla, Apr 21, 2020
  8. Junio C HamanoApr 21, 2020
  9. Randall S. BeckerApr 21, 2020
  10. Junio C HamanoApr 21, 2020
  11. Randall S. BeckerApr 21, 2020
  12. Derrick StoleeApr 22, 2020
  13. Jonathan NiederApr 22, 2020
  14. Elijah NewrenApr 22, 2020
  15. 4/4 gitfaq: fetching and pulling a repositoryShourya Shukla, Apr 21, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.