Because there is the Sourcetree tag in the question I will answer you how to do this with Sourcetree, it's really simple.
As said before you first have to remove the file from tracking and then make Sourcetree to ignore the file.
- Change something in the file so that it is shown to you or select it from the "file status" tab at the bottom of the open repository.
- Right click on the file and you see "Ignore...", but it is grayed out because as said above its already in track.
- Right click on the file and chose "Stop Tracking"
- The file will be shown with a red button which indicates it will be removed (from tracking)
- A new entry of the same file will be shown in "file status" with a blue question mark indicates a new file (new because you said remove from tracking in 4)
- Right click on the file from 5 and now you see the "Ignore..." is able to choose. Click on it and Sourcetree will put a new entry for the file in the .gitignore file
- You can see the .gitignore file if you click on "Setting" on the top right, choose "advanced" and then the first entry is about the ignore file, click on "edit" and it will be open.