Create .gitignore and other hidden files on Windows

If you ever needed to create a hidden file (.)filename on Windows then you'll have noticed that it's not particularly intuitive or easy to do. By default, Windows Explorer does not allow you do this in the GUI. Why? No idea!

Solution 1

One easy and fast way to create files with a prepending (.) in the name (e.g .gitignore) is to open the Command Prompt and navigate to the directory you need to create your file. Alternatively, if you're already on the desired directory in the Explorer, you can Alt+RighClick and use Open Command Prompt from the context menu (pro tip!). In this instance we'll assume you need a .gitignore file.

cd c:\<your path>
notepad .gitignore

Accept the prompt to create the file, edit the contents accordingly, save and close.

Solution 2

Apparently real people and not just bots or crawlers visit my blog! Thanks to them (in the comments below and on Twitter) I now have a second solution to our problem. One that requires no CMD and can be done in the GUI for those of us that prefer the use of mouse and windows.

You can create hidden files using the Windows Explorer by following these steps:

  1. Navigate to your preferred location
  2. Right click and add a new Text Document
  3. Rename the file to .desiredFileName. (notice the 2 dots one before and one after)
  4. Save and close

Job done!

  • Share this post on