Automation, Orchestration, and Scripting

A developer committed app.log to a repository by mistake. They then added *.log to .gitignore, but git status still shows app.log as modified after each run of the application. What should the developer do to stop Git from tracking the file while keeping it on disk?

Show the answer

Correct answerC. Run git rm --cached app.log and commit the removal

A .gitignore rule only affects untracked files, so an already tracked file must be removed from the index with git rm --cached, then committed. git clean is tempting, but it deletes untracked files and does not change what the index tracks.