Video in progress

Strong Junior 🌿 Git

You added `application-local.yml` to `.gitignore`, but Git still shows changes to it. Why, and how do you fix it?

The file was committed earlier, so Git is already tracking it, and .gitignore works only on untracked files. You need to remove the file from the index with git rm --cached and commit that change.

📖 Answer

git rm --cached src/main/resources/application-local.yml
git commit -m "application-local.yml repository'dan chiqarildi"

--cached does not delete the file from disk, it only tells Git "stop tracking this". For a whole folder: git rm -r --cached .idea/.

There is a trap: when others pull this commit, the file disappears from their disk, because for Git it means "the file was deleted". So warn the team in advance, or leave a sample file such as application-local.yml.example in the repository.

To find out which rule is holding a file: git check-ignore -v path/to/file shows which line of which .gitignore is in effect.