From c8dc07ddd079c6a9a04b1e70eabbefe63928bc71 Mon Sep 17 00:00:00 2001 From: Jan Simson Date: Sun, 21 Jul 2024 13:00:18 +0200 Subject: [PATCH] Add notice on ignoring tracked files --- 2.1-gitignore.qmd | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/2.1-gitignore.qmd b/2.1-gitignore.qmd index fd7ac0c..bb71e80 100644 --- a/2.1-gitignore.qmd +++ b/2.1-gitignore.qmd @@ -35,13 +35,24 @@ Ignore all PDF files The .gitignore uses the same kind of pattern matching as `git add` (or other git commands) ::: -## `.gitignore`: global vs. local +## `.gitignore`: global vs. local 🫥 - There can be multiple different `.gitignore` files at different levels - There's one *global* `.gitignore`, that will work across your whole computer - There are local gitignore files within your repositories - You can even have a gitignore file in a directory within your repository and it will apply only within that directory -- You can find a list of very useful templates for `.gitignore` files at . + - You can find a list of very useful templates for local`.gitignore` files at . + - A classic example for files to ignore globally are `.DS_Store` files on macOS. + +## Once it's in, it's too late + +Once a file is tracked by `git`, adding it to the `.gitignore` will not do anything. + +- You will first have to remove it from git +- **Option 1:** Delete the file and commit the deletion +- **Option 2:** Remove file from index only (and commit) + - `git rm --cached ` + - ⚠️ Warning: This will delete the file for anyone else working with the repository! ## Practical: Ignoring Files {background-color="black"}