Git, stop tracking a file, but keep it localy

In order to stop tracking a file in git then rm is used – however this will delete the file from my local directory as well. The following will stop tracking the file, but keep it on my local computer.

git rm --cached path/filename

After this step, it is very likely that the file should be added to a .gitignore file;)