I couldn't hide my file using .gitignore file in GitHub repositories

I’m very new to Github. Today I tried to hide a file in my repositories using the .gitignore file. I typed the file name on the .gitignore file. But that file still appears in the repositories.

Can someone help me step by step with how to do it?

A .gitignore file does not apply to files that are already part of the index. Could you describe what exactly you are trying to achieve?

Thanks for your support @airtower-luna. I created this topic for how to create .gitignore file. Using .gitignore, how to hide a particular file from public view. Now I learned from this video Part 4 - How to use .gitignore [Git-ing Started with Git Series] - YouTube. I am able to hide the file from public view now.