> ## Documentation Index
> Fetch the complete documentation index at: https://mage-staging.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# File versioning in Mage

> Mage can automatically keep track of previous versions of a file.

## Overview

Mage has file versioning built-in— that means you don't need to configure Git to roll-back changes or recover old file versions.

Any update to the contents of a file will create a new version that can be used to restore a file to a previous state. This also includes changes to a pipeline.

## Configure the number of versions per file

You can set how many previous versions to keep track of for every file.

Set the following environment variable name and value:

|         |                               |
| ------- | ----------------------------- |
| Name    | `MAX_NUMBER_OF_FILE_VERSIONS` |
| Value   | Any integer value.            |
| Default | `100`                         |

## Where are the file versions stored?

Each file version is stored in the following directory:

```
[project_name]/.file_versions
```

For example, if your project name is `demo_project`, then the directory will be `demo_project/.file_versions`.

Please add `.file_versions` to your `.gitignore` file.
For more information, please read the [project setup guide](/development/project/setup#create-a-gitignore-file).

## How to view file versions

1. Open a pipeline.
2. Edit the pipeline.
3. In the file browser on the left side of the page, click on a file.
4. Near the top on the right side, click the button <b>Show versions</b>.
5. A list of previous versions for that file will appear in the right side panel.

<Frame>
  <img alt="File versions" src="https://github.com/mage-ai/assets/blob/main/notebook/file-versions.jpg?raw=true" />
</Frame>

## How to restore to a previous version

1. In the right side panel, click on a previous version.
2. Click the button labeled <b>Replace with this version</b>.
3. The contents of the file will be updated with the contents from the previous version.
