> ## Documentation Index
> Fetch the complete documentation index at: https://flox.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# What is a generation?

> Everything you need to know about generations.

Generations refer to a **version number of an environment** on
[FloxHub](/concepts/floxhub).
Both imperative and declarative commands that modify an environment on
FloxHub increment the generation number for the environment.

Read more about creating your first generation in the
[sharing guide](/tutorials/sharing-environments).

## First generation

The first environment generation (1) is created when you use
**[`flox push`](/man/flox-push)** to send an environment to
[FloxHub](/concepts/floxhub).

## New generations

**New generations are created automatically** when you use a CLI command that
modifies the environment,
such as [`flox install`](/man/flox-install) or [`flox edit`](/man/flox-edit).

## Staged local generations

With a [FloxHub environment](/tutorials/creating-environments) **new local
generations are staged automatically**,
whether you pull into a directory or use `--reference`.
Suppose you [`flox pull`](/man/flox-pull) an environment at generation 15 on
[FloxHub](/concepts/floxhub).
If you now run [`flox install`](/man/flox-install) three times then you will have
generations 16-18 locally.
The next [`flox push`](/man/flox-push) would sync these three new generations to
FloxHub if you have permission to write to the environment.

## Switching and viewing generations

Generations offer change management for environments;
it's similar to `git`, but tailored for environments.

Suppose you make an edit to an environment,
but then after activating and using the environment, you want to undo the change
you just made.
To undo the change, you can run `flox generations rollback`.

If you've made a series of edits over time but later realize you want to discard them all,
you can use `flox generations list` to display all the different versions of the environment, and then you can use `flox generations switch <generation number>`
to revert to the version of the environment prior to all those edits.
You can also view generations on FloxHub on the `Generations` tab of an
environment's page.

## History

Rolling back to a previous generation introduces another concept:
history.
Rolling back doesn't create a new generation, but it does add an entry to the environment's history.
Suppose you `flox generations rollback` from generation 18 to 17.
Although the list of generations hasn't changed, the latest entry in the environment's history will now say that generation 17 is the live generation.
Note that although generation 18 is the "latest" in the sense that it has the
highest generation number and was most recently created, it is not the latest to
be live.

This history of what generation is live at a given point in time can be
viewed on FloxHub on the `History` tab for an environment.
Or, to use the CLI to view history, you can run `flox generations history`.
This provides a log of what generation of an environment was live at the time
an environment was pulled.

## Generation lock

[FloxHub environments](/tutorials/creating-environments) that are pulled with
[`flox pull`](/man/flox-pull) will store a generation lock which describes
**the current pulled generation**.
This allows this environment to advance to newer generations explicitly on the
next [`flox pull`](/man/flox-pull).
