To create a gitignore file follow the below steps:
First, create a text file gitignore.txt. Then open the text file in a text editor and add rules to it and save the file. Then press SHIFT+RIGHT_CLICK on the folder then open the command window here. There you need to rename the file in the command line using
ren gitignore.txt .gitignore
You can get around this Windows Explorer error by appending a dot to the filename without extension: .gitignore. Then it will automatically be changed to .gitignore.
Thus you can create a .gitignore file.