Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript npm Basics Managing Packages with NPM Ignore Files and Directories with gitignore

Lyndsay Labrecque
Lyndsay Labrecque
334 Points

How exactly does someone create a .gitignore file?

I can infer it's done in Visual Studio, but no information about this is provided.

3 Answers

You can create a new file in VS Code by clicking File --> New File, by pressing CTRL + N (on a PC - it's probably Command + N on a Mac), or by clicking the first icon next to the folder name in the explorer view (it looks like a piece of paper with a plus sign on the bottom right corner). Alternatively, you can just create a new file in the folder in your operating system without using VS Code. If you do this, just be sure that you have the options set to see hidden files and folders, as files that start with a period are hidden by default (at least on a PC).

Thanks Jason! Is there a way to do this in the terminal? I know mkdir is to create a file directory, I feel like there is a way to create an individual (text?) file but I've forgotten it.

I don't normally use a terminal, but I believe the command you're looking for is touch, or more specifically, touch .gitignore.

@Olivia, I know this is super old, but for those who are looking for an answer, the answer would be

touch .gitignore