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

# Workflow

> Common ways to use Anchor4Git in real-life situations.

## Daily team workflow

This is the normal rhythm when working with a team:

```bash theme={null}
# Morning: get the latest from the team
ag fetch

# Work on your tasks (edit files all day)

# Before lunch: save your progress
ag save "Working on the dashboard"

# After lunch: save and share
ag save "Finished the dashboard layout"
ag upload

# End of day: make sure everything is shared
ag info          # Check your status
ag upload        # Upload if you have unsaved work
```

## First time joining a project

When you're new to a project:

```bash theme={null}
# 1. Download the project (do this once)
ag fetch https://github.com/team/project.git

# 2. Check the dashboard to see what's happening
ag info

# 3. Start working!
```

## Handling merge conflicts

Sometimes your changes and the team's changes clash. Here's what to do:

### When it happens

You run `ag fetch` and see:

```text theme={null}
[WARN] Conflicts detected:
    • index.html
    • style.css
```

### Step-by-step resolution

<Steps>
  <Step title="Open the listed files in your editor" />

  <Step title="Look for conflict markers">
    ```text theme={null}
    <<<<<<< HEAD
    Your version of the code
    =======
    Their version of the code
    >>>>>>>
    ```

    * `<<<<<<< HEAD` = your changes
    * `=======` = divider between versions
    * `>>>>>>>` = their changes
  </Step>

  <Step title="Edit the file to keep what you want">
    You can:

    * Keep your version (delete the markers and their version)
    * Keep their version (delete the markers and your version)
    * Mix both versions together manually
  </Step>

  <Step title="Remove all the conflict markers (<<<<<<<, =======, >>>>>>>)" />

  <Step title="Save the file in your editor" />

  <Step title="Tell Anchor4Git you're done">
    ```bash theme={null}
    ag save
    ```

    <Warning>
      This step is important as if you do not do this; **upload** will be blocked.
    </Warning>
  </Step>

  <Step title="Share your resolution">
    ```bash theme={null}
    ag upload
    ```
  </Step>
</Steps>

### Example: Resolving a conflict

Before (conflicted file):

```text theme={null}
<<<<<<< HEAD
Welcome to our site
=======
Welcome to our website!
>>>>>>>
```

After (resolved):

```text theme={null}
Welcome to our website!
```

Then save and upload as normal.

## Going back to an old version

### Look at an old version (temporary)

```bash theme={null}
# See what the project looked like at an earlier save
ag goto abc1234

# Look around... then press Enter in the terminal to return
```

### Roll back to an old version (permanent)

```bash theme={null}
# Find the save you want to go back to
ag info

# Permanently go back
ag goto abc1234 --reset
```

### Stay on an old version

```bash theme={null}
# Go to old version and stay there
ag goto abc1234 --stay

# When you want to come back
ag goto HEAD
```

> To find the save ID, run `ag info`

## Setting up a shared project from scratch

If you're the team lead starting a new project:

```bash theme={null}
# 1. Create a shared repository on GitHub, GitLab, etc.
#    (this step depends on your git repository provider)

# 2. Create the project locally
mkdir my-project
cd my-project
ag init "My Project"

# 3. Fetch it locally to sync details
ag fetch https://github.com/team/my-project.git

# 4. Save the initial setup
ag save "Initial project setup"

# 5. Upload the project
ag upload

# 6. Tell your team to run:
#    ag fetch https://github.com/team/my-project.git
```

> You'll need to set up authentication (like a personal access token) for GitHub/GitLab. Check their documentation for help.<br />Anchor4Git automatically handles login to major providers like GitHub using a UI.

## Quick reference

| Situation           | Command                |
| ------------------- | ---------------------- |
| First time setup    | `ag fetch <url>`       |
| Daily download      | `ag fetch`             |
| Save progress       | `ag save "what I did"` |
| Share with team     | `ag upload`            |
| Check status        | `ag info`              |
| Look at old version | `ag goto <id>`         |
| Return to latest    | `ag goto HEAD`         |
| Change settings     | `ag config`            |
