About this question
There is a file that was being tracked by git, but now the file is on the .gitignore list.
However, that file keeps showing up in git status after it's edited. How do you force git to completely forget about it?
There is a file that was being tracked by git, but now the file is on the .gitignore list.
However, that file keeps showing up in git status after it's edited. How do you force git to completely forget about it?
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask DevOps Expert
Answered on Apr 2, 2021
To let git stop tracking a file you need to remove the file from index.
For removing a file from the index:
git rm --cachedNote: This command will not delete a physical file in local but will delete the file from other developers from the next $git pull command.
Also, you can go with the following commands
git rm -r -- cached.
git add .Then commit the file with -am then the file gets updated and then the file cannot be tracked.
.gitignore will prevent untracked files from being added so instead of .gitignore you can remove the file from the index so that the file cannot be tracked.
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common DevOps interview questions, answered
Guides, tips and career advice on DevOps from JanBask experts.
DevOps How to Become a DevOps Engineers: Learning Path, Critical skills & More
Looking for answer to how to become a DevOps engineer in 2025? Here is the detailed article about DevOps career path, DevOps…
DevOps Top 50+ Jenkins Interview Questions And Answers For 2025
Here are the Top 50 Jenkins interview questions frequently asked in top MNCs which will help you land an ideal job! These…
DevOps Best 37 DevOps Tools To Learn And Master In 2025: Docker, Git & More
Want to know what are Devops tools and their uses? Or looking for the best DevOps list for automation, monitoring, & development?…
DevOps DevOps Engineer Job Description: Roles and Responsibilities [2025 Updated]
Discover the essential roles and responsibilities of a DevOps Engineer by exploring the detailed DevOps job description, and…