Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

touch .gitignore not creating file

I'm trying to set up a React dev environment, and one instruction I've been given is to enter my directory in Terminal and type this code:

touch .gitignore

The touch command works fine when I'm making a file with a name and extension (e.g. index.html) but since this appears to be only an extension, nothing is happening.

Apparently it's an important file regarding uploading to GitHub - can anyone help?


Update: I created x.gitignore, and then tried deleting the x, and it OSX throws up a dialog saying:

You can’t use a name that begins with a dot “.”, because these names are reserved for the system. Please choose another name.
like image 581
Paulos3000 Avatar asked Oct 24 '25 14:10

Paulos3000


1 Answers

You can see all of the visible files within a folder by typing

ls

into your terminal (assuming OSX from your comment). However, you will only see a list of the non-hidden files. You can see all files by typing

ls -a

Your .gitignore file basically tells git which folders and files to disregard when packaging everything up to be stored. For example, in ReactJS projects you are probably going to be using a lot of NPM packages and you wouldn't want to include them in your git repository. So, in your .gitignore file, you would include a line that says

node_modules

and then none of the files or folders within node_modules would be included when you push to Github (or Bitbucket or wherever).

If you are having trouble finding the .gitignore file, first run the ls -a and make sure that you see the file listed. After that, if you are having trouble seeing the file in your text editor, you may want to check the preferences in the text editor.

In Atom, you need to unselect "View VCS Ignored Paths" to see the "ignored" files.

like image 96
nallenanderson Avatar answered Oct 27 '25 03:10

nallenanderson