.gitignore
.gitignore is a simple text file that tells the Git version control system which files not to track and not to upload to the shared code repository.
In plain terms
Imagine you are moving house and place a note next to the boxes for the movers: 'do not bring the trash, the key ring, or the food left in the fridge'. A .gitignore file is just such a note in a software project folder. It lists what can stay on your machine but does not belong in the shared version.
The Git version control system by default detects every file in the project folder and offers to save it. However, many files have no business in the shared repository: these include temporary files, huge folders generated by your machine, personal settings, and especially files containing passwords and access keys.
This file is not a program, nor is it protection: it is just a list, with one pattern per line. It is for Git; it does not delete or hide files on your machine. In the AI era, it has become more important because many coding agents consult it when deciding which files to work on. Additionally, an agent can easily upload something it should not.
How it works
- In the project's root folder, you create a text file named .gitignore. Its name starts with a dot, so it appears as a hidden file on many systems.
- You write one pattern per line: it can be a specific filename (e.g., .env), a folder (node_modules/), or a wildcard pattern (*.log, meaning every file ending in .log).
- When Git scans the folder, it simply skips untracked files matching the patterns: it does not flag them as changes, and they are not included in the save.
- You can make an exception with an exclamation mark (!important.log). This does not work if you have excluded the entire folder containing the file. Subfolders can also have their own .gitignore file, which applies only to that section.
- You usually upload the .gitignore file itself to the shared repository, so the same rules apply to every team member and the coding agent.
An everyday example
You try an AI tool requiring a paid API key and save the key in a file named .env in your project folder. If .env is on the .gitignore list, the key stays on your machine when you upload the code to GitHub. If it is not, the key may become public, and someone else could spend your money within minutes.
Who is affected
A common misconception
Limits and risks
- It is not a security tool: it does not encrypt or protect, but only asks Git to exclude certain files.
- It does not work retroactively, so it is worth preparing before the very first project save.
- A typo or an overly broad pattern can omit important files, and this often only becomes apparent when the program fails to start on a colleague's machine.
- Coding agents usually take this into account, but it varies by tool, so before uploading, check what the agent is about to save.
Similar, but not the same
- .env file – The .env file itself stores secret keys and settings, while .gitignore only tells Git not to upload this file.
- Delete File – .gitignore deletes nothing: the excluded file remains on your machine, the version control system simply ignores it.
- Access Management – Permissions regulate who can see the code repository, while .gitignore determines what is included at all.
Related concepts
global .gitignore, gitignore-sablon
code repository, commit, GitHub, API key, environment variable
A brief history
Git, the version control system, was launched by Linus Torvalds in 2005, and the list of files to be ignored became part of the system very early. The solution was not new: earlier version control systems, such as CVS, used similar 'ignore' files.
Where things stand
At the end of 2026, it is present in practically every project that uses Git, and development tools and GitHub offer ready-made templates for it. With the spread of coding agents, its role has grown, and several AI tools have introduced their own exclusion lists based on a similar principle.
Also known as
.gitignore · gitignore · gitignore file · git ignore · ignore file · exclusion list · gitignore file
Sources
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.