Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"You must type a file name" error thrown, when I create a .gitignore file on Windows

When I try to do this, I get the following error:

gitignore error

Obviously, Windows Explorer doesn't allow me to create this type of file patterns. How can I overcome this problem?

like image 896
leventunver Avatar asked Feb 06 '16 19:02

leventunver


People also ask

How do I Gitignore a file?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Where do I put the .gitignore file?

A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .


2 Answers

I arrive a little late but will give you the trick!! πŸ˜‰

In the File Explorer, call your file .gitignore. and it will remove the ending '.'

A strange behavior from the file explorer but, hey!, it works πŸ˜…

Or create it from a text editor...

like image 67
Philippe Avatar answered Oct 13 '22 20:10

Philippe


Windows Explorer doesn't allow you to create files that consist essentially of a file extension only. This is because Windows Explorer has the option to hide file extensions, leaving you with a file you cannot see (see Why doesn’t Explorer let you create a file whose name begins with a dot?). This is not a restriction of Windows itself, or the file system in use, though.

To create a file named .gitignore, you will have to use another tool to create it. A common solution is to create a text file (e.g. test.txt), open it in Notepad, and select Save As... to rename the file to .gitignore.

The Windows command interpreter also allows you to create files without imposing the additional restrictions of Windows Explorer. A more direct solution would then be to create the file from the command line. This can be done using the following command:

copy NUL .gitignore 


Note: When dealing with files that don't have a name, it's helpful to disable the option "Hide extensions for known file types" in Windows Explorer. Otherwise Windows Explorer might show files with no names, or hide them altogether.
like image 21
IInspectable Avatar answered Oct 13 '22 22:10

IInspectable