Windows Explorer doesn’t allow you to create a file without a name:
Windows doesn’t have a native “touch” equivalent, which is a native Linux program that allows you to create empty files and change timestamps.
If you run “touch>.gitignore” (or any of the other options below) from the command line, the file is created. Also, if you run it again, the file’s timestamp will be updated. It won’t change attributes like touch on Linux does.
Here are some other ways that work as well.
- copy nul .gitignore
- copy con .gitignore, hit enter, then hit ctrl+z
- cat>.gitignore, hit enter, then hit ctrl+c
- echo > .gitignore
- fsutil file createnew .gitignore 0
- nul > .gitignore
- notepad .gitignore
- In Windows Explorer, name the file “.gitignore.” and Windows will rename it to “.gitignore”
- bash -c “touch .gitignore”
Let me know if you know of any other ways and I’ll add them to the list.