Skip to content
CodeKruPro

.gitignore does not stop a tracked file

QuizMediumAsked in: Accenture, Capgemini, TCS, Wipro

config.properties with a test password was committed last week. You now add it to .gitignore, but Git still shows changes to it. Why, and what do you do?

  • .gitignore only affects untracked files (files Git has never recorded); run git rm --cached config.properties and commit, and change the password because it is still in history
  • .gitignore needs a restart of Git to take effect
  • Delete the file from disk; Git then forgets its history
  • Add the file twice to .gitignore

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in