# History, branches and Git

> Every save of a project is a Git commit. See what changed, restore any version, try an idea on a branch, or clone the project and push to it.

## Every save is a commit

Each save of a project (its document, strategies, scripts and workflows) is a Git commit on its current branch, kept by ftw.trade and mirrored to the project's own repository.

| File | Holds |
|---|---|
| `project.json` | The project document |
| `strategies/<id>.flow` | Each strategy in the project |
| `scripts/<name>.ts` | Each script |
| `workflows/<name>.json` | Each workflow |
| `dashboard.json` | The dashboard, restorable on its own |

## See and restore

- **History** lists commits newest first with the files each changed, and what isn't committed yet.
- **Diff** any two versions, or a version against now.
- **Restore** a version, or just some files. Wallets and paper or live mode stay as they are; a script comes back as a new version to deploy; running workflows are left alone.
- **Commit** with a message before something risky, so it's easy to find again.

## Branches

Try an idea on a branch: create it and switch to it, change things, compare it with `main`, then switch back to drop it or restore it onto `main` to keep it.

## Clone and push

Ask for Git access (from the project, or `get_project_git_access`) and you get a clone command with a token for an hour. Push a new branch, then pull it into the project and switch to it.

```sh
git clone https://…/project.git
cd project && git checkout -b tighter-stops
# edit strategies/momentum.flow
git commit -am "Tighter stops" && git push -u origin tighter-stops
```

From the CLI, `ftw-trade push` saves a folder's scripts and `.source.flow` sources to a project, and `ftw-trade strategies save` saves `.flow` strategies, so you can keep them in your own repository too.
