# Git Integration

> Your whole API Maker project in Git - branches, pull, push with a commit, status and diff of every change, revert, secrets kept out, migration scripts run after a pull, and deployment hooks for CI.

Source: https://docs.apimaker.dev/v1/docs/Git/git.html

Everything you build in API Maker is text : schemas, custom APIs, hooks, events, schedulers, settings, groups, test cases… API Maker keeps it in a Git repository of yours, branch by branch, and pulls it back on any other server.

| | |
|---|---|
| Set up | Profile → **User info** : the Git URL with credentials, and the email of the commit user. |
| Branch | The **Branch list** of the Git panel ; the branch selected is the one pulled and pushed. **Create branch** from another one, **Delete branch**. |
| Pull | Replaces the code of the account with the branch, then runs the [migration scripts](/v1/docs/features/database-migration.html) not yet executed here. |
| Push | Shows the status, lets you compare and revert, then commits with your message. Pull requests are raised in your Git host. |
| Never in Git | Secrets and notes. |

## What goes to Git

- One folder per kind, one folder per item, the code as `.ts` and the settings as YAML : `Custom APIs`, `Schemas`, `Instances`, `Instance API settings`, the four kinds of hooks, `Events`, `WebSocket events`, `Schedulers`, `Process initializers`, `Database migrations`, `Utility classes`, `Test cases`, `Groups`, `API users`, `Auth Providers`, `i18ns`, `Log profiles`, `API testing states`, `Auto Increments`, the `API Security Report`…
- Secrets never leave the server. Each environment keeps its own, which is the point : the same code runs against another database because the secret differs.
- The folder is what the [local client](/v1/docs/getting-started/local-run.html#your-code-in-your-editor-the-local-client) syncs to your disk, so the same files open in your editor.

## Pull

1. Pick the branch, click **Pull**. The panel logs **Steps on the server**.
2. The items of the branch replace the ones of the account. **Last pulled branch** shows what the server runs.
3. The active migration scripts which never ran on this environment are listed : run them, in order.

- **Pull Without Secret** (in the Pull dropdown) : for a repository made on another installation, whose `passDBEncryptDecrypt` differs. The passwords of the API users can not be decrypted, so they are set to read their password from the secret (`common.apiUserPasswords.default`). Add those passwords to your secret.

## Push

1. **Git status of commit** lists every file which differs from the branch : added, modified, deleted. Filter the list, expand all.
2. **Compare** opens one file in the compare editor ; **View all changes in one diff** shows them together.
3. **Revert** puts a file (or the files selected) back to the branch, in the account too.
4. Write the message and **Commit changes to branch** : the commit is pushed.

- Renaming a hook shows as one file deleted and one added : the folder is its name.

## Deployment hooks

- A deployment hook is an URL of your server which pulls a branch, for a CI pipeline or the webhook of your Git host. Create it in the Git panel : a name, an access token and a secret, and the IPs allowed to call it.

```text
POST /api/sites/deploy/<user path>/<hook name>?token=<access token>&secret=<secret>&branch=main
```

- `syncMode=SYNC_WITHOUT_SECRET` pulls like the Pull Without Secret button ; `runMigrationScripts=false` skips the migration scripts.
- The last callers are kept, so the panel can show where the deployments came from.

## Related

- [Database migration scripts](/v1/docs/features/database-migration.html) · [Developer accounts](/v1/docs/dev-accounts/dev-accounts.html) · [Secrets](/v1/docs/secrets/secrets.html) · [Local client](/v1/docs/getting-started/local-run.html)
