Don't Ignore .gitignore

Why you should never ignore .gitignore

If you are a developer or have used git, you might have heard the term gitignore. So what is a .gitignore and why should you stop ignoring it.

What is a .gitignore?

A gitignore is a special file that specifies intentionally untracked files that Git should ignore. Sometimes there might be files in your project which you don’t want to commit to the version control for reasons like:

  1. The file might hold some secret information like your API key/secret, APP secrets, or some username/password, server config, etc.

  2. It might contain some configuration specific to your machine only and don’t want to commit to the version control

  3. It might be some installed dependencies like node_modules or bower_components

  4. It might be a machine specific useless file like .DS_store files

Gitignore is a great way to avoid unwanted files to be pushed to the server. But do I really need to learn now?

Dark Side of gitignore

What will happen if you ignore .gitignore

Odoo image and text block

If you have come credentials or config file on your project you should take gitignore seriously. If you ignore the .gitignore you might leak your secret credentials yourself. If you search on Github for some config files you can find out the emails/passwords, API keys, and APP secret keys of many projects. If on the wrong hands you might be in trouble since they can change the credentials or even use it for the wrong this like sending spam and pushing updates with exploits.

For example, searching filename .env with password

will give you a bunch of credentials.

The author is not responsible for the illegal use of the provided URL. The URL is provided for informational use and awareness only

Now that we agree on not ignoring the gitignore,

How can we implement it

How to use gitignore

Using gitignore is as easy as creating a file and entering the file name you don’t want to push inside the file. You can also ignore files as well as folders. Also, you can use pattern formats to ignore a bunch of files and folders at once. For example, you can use *.c to ignore all files with the file extension c. You can learn about the various patterns you can use in gitignore here. If you are creating a project on GitHub, GitLab, etc you can choose the .gitignore file template according to the project framework or language you are going to use and it will generate a .gitignore file for you. Moreover, you can gitignore generator like

- Aatish Sai


Some rights reserved