1. Via Github Web InterfaceWhen working with my Number Wizard game project, I created the git repository via Github web interface and I can choose to add .gitignore from the Add gitignore dropdown list.
|Unity Game Development - .gitignore via Github web interface|
2. Add .gitignore For Existing Project
1. Find the correct gitignore file from this link. For Unity, I'm using this file.
2. Go to your repository folder/directory and create ".gitignore" file in the root of your repo folder.
In windows you can just create and empty file or in Mac you can use "touch .gitignore". In Linux or Mac based system, ".gitignore" file by default would be hidden. You can use "ls -a" to see your file or you can follow this simple tutorial to show hidden files on Mac.
3. Open your empty ".gitignore" file and paste this content and save the change:
4. Run the following commands on you terminal:
- git rm -r --cached .
- git add .
- git commit -m ".gitignore is now working"
Please be aware on the first and second commands there is [dot] character there.
Actually this solution works for any gitignore files do you want to add to your repository. If you find this tutorial useful, please leave a comment bellow. Thank you.