# Git workflow

Git is the source of truth for all Comind.work app code. Every change you make - whether to actions, views, or configuration - should live in your Git repository first and get deployed to AppCode from there.

## The safe workflow[​](#the-safe-workflow "Direct link to The safe workflow")

Follow these five steps every time you work on app code:

<!-- -->

### Step 1: Pull the latest state from AppCode[​](#step-1-pull-the-latest-state-from-appcode "Direct link to Step 1: Pull the latest state from AppCode")

Before editing anything, download the current AppCode state to make sure you have any changes made through the web UI:

```
npx comind pull app-your-task
```

### Step 2: Edit locally[​](#step-2-edit-locally "Direct link to Step 2: Edit locally")

Make your changes in your local editor or Codespace. All app source files live in the repository under their respective app folders.

### Step 3: Install to deploy[​](#step-3-install-to-deploy "Direct link to Step 3: Install to deploy")

Deploy your changes to the target environment:

```
npx comind install app-your-task
```

The `install` command compiles and uploads your app code to AppCode in a single atomic operation.

### Step 4: Verify on the site[​](#step-4-verify-on-the-site "Direct link to Step 4: Verify on the site")

Open the Comind.work site and confirm your changes work as expected. Test the relevant views, actions, and workflows before moving on.

### Step 5: Commit to Git[​](#step-5-commit-to-git "Direct link to Step 5: Commit to Git")

Once verified, commit your changes:

```
git add app-your-task/
git commit -m "Describe what you changed and why"
```

## Bidirectional sync with AppCode[​](#bidirectional-sync-with-appcode "Direct link to Bidirectional sync with AppCode")

The CLI provides two sync commands:

* **`push`** - uploads source files from your local repository to AppCode
* **`pull`** - downloads the current AppCode state to your local repository

Both commands work per-app. See the [CLI reference](/developer-guide/reference/cli-reference.md) for full syntax and options.

Danger zone - unsynced web UI edits

If someone edits app code directly in the AppCode web editor, those changes only exist on the server. Running `install` or `push` without pulling first will overwrite them. Always `pull` before you `push` if anyone uses the web editor.

## Branching strategy[​](#branching-strategy "Direct link to Branching strategy")

Comind.work repositories use two long-lived branches:

| Branch | Deploys to              | Requirements                  |
| ------ | ----------------------- | ----------------------------- |
| `main` | Development environment | Standard commits              |
| `prod` | Production environment  | Signed commits by admin users |

### Main branch[​](#main-branch "Direct link to Main branch")

The `main` branch auto-deploys to the development environment. All day-to-day work happens here. Use feature branches and pull requests if your team prefers code review before merging to `main`.

### Prod branch[​](#prod-branch "Direct link to Prod branch")

The `prod` branch auto-deploys to production. Pushes to `prod` require signed commits from admin users - this ensures only verified, trusted code reaches production.

To set up commit signing, follow the [signed commits guide](/developer-guide/getting-started/sign-commits.md).

## When someone edits in the web UI[​](#when-someone-edits-in-the-web-ui "Direct link to When someone edits in the web UI")

If a team member makes changes directly in the AppCode web editor:

1. Run `npx comind pull app-your-task` to download their changes
2. Review the diff in Git to understand what changed
3. Commit the pulled changes to preserve them in version control
4. Continue with your normal workflow

Skipping the pull step risks losing their work on the next `install` or `push`.
