loading...

The Gitignore file

zellwk profile image Zell Liew 🤗 Originally published at zellwk.com ・1 min read

If you don't want to commit a file into a Git repository, it makes sense not to have the file show up in the staging area.

You can do this with a Gitignore file.

In the video, we installed a library called Typi with npm. Many files come into our staging area when we installed Typi.

Node modules files in staging area

To prevent node_modules and its files from appearing in the staging area, you:

  1. Create a .gitignore file at the root of the project
  2. Add node_modules in the Gitignore file

And the staging area becomes clean. AT this point, you want to commit your .gitignore file to preserve what to ignore.

Node modules removed from staging area

How to use Gitignore

Each line in the Gitignore file can be used to match files and folders you don't want to see in the staging area.

  1. To ignore a file, you write the file name.
  2. To ignore a folder, you write the folder name
  3. To ignore an extension, you can use a * wildcard, like *.log

Thanks for reading. This article was originally posted on my blog. Sign up for my newsletter if you want more articles to help you become a better frontend developer.

Posted on by:

zellwk profile

Zell Liew 🤗

@zellwk

Frontend consultant; teaching frontend to self-taught devs at http://zellwk.com. Currently attempting to demystify Javascript at http://learnjavascript.today.

Discussion

pic
Editor guide