Once in a while I am pushing to server things I don’t really need there. Like I did recently and pushed my sqlite database. I want to keep the file localy but remove it only from a server.
It is very simple:
git rm --cached myfile_or_directory
then just commit and push changes:
git add . && git commit && git push
Thing to remeber is to add that file or directory to gitignore so that you will not push it again.
If you don’t have one yet just create a file:
.gitignore and list there all files you want to ignore.
myfile.rb directory/ other_directory_example/my_other_file_example.js