How to stop tracking a file in Git using the .gitignore file

The .gitignore file is used in Git to ignore some unwanted files (e.g. .o, .obj, .exe files). The .gitignore file specifies intentionally untracked files to ignore.

If you want to untrack some files that are tracked, first you have to remove the file from the index (repository cache) and then you have to add to the .gitignore.

V.gr, if you want to untrack the tracked «style.css» file, first you have to untrack it using the «git rm» command

$ git rm --cached style.css

and then you have to add the filename («style.css») to the «.gitignore» file using a text editor or the command

$ echo 'style.css' >> .gitignore

 

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.