To stop tracking a file you need to remove the file from index.
For removing a file from the index:
git rm --cached<file>
Note: This command will not delete a physical file in local it 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.
For better understanding about these commands go through the following crash course on git that will help you to understand git well