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

# Git attribution

> Deploy git-ai to track AI-assisted code changes at the git level

Git attribution tracks AI-assisted code changes at the git level, providing accurate attribution data for commits made with AI coding tools. It works by installing a lightweight binary that wraps `git` on each developer's machine, automatically recording which lines of code were authored with AI assistance.

## What's tracked

* **AI authorship** — Which lines of code were written with AI assistance
* **Tool attribution** — Which AI tool contributed to each change (e.g., Cursor, Claude Code, Copilot)
* **Commit-level data** — Per-commit AI vs human contribution breakdown

## How it works

Git attribution uses [git-ai](https://github.com/git-ai-project/git-ai), which installs a binary that sits on the developer's `PATH` in front of `git`. Whenever any process calls `git`, the git-ai binary intercepts the call.

In addition to the binary itself, the install script configures **hooks** into each detected AI coding tool on the machine (e.g., updating Claude Code's config, Cursor's settings, etc.). These hooks notify git-ai whenever an AI tool generates code — a "post tool use" callback that records which tool was used and what code it produced.

When a developer makes a commit, git-ai reconciles all recorded AI activity against the commit's diff to determine exactly which lines were AI-assisted and which were human-written. This data is stored as git notes (`refs/notes/ai`) and pushed alongside regular commits.

Weave reads this metadata during repository sync to attribute code contributions accurately.

## Prerequisites

* Admin access to your Weave organization
* For organization-wide deployment: an MDM solution (Fleet, Intune, Kandji, Jamf, or similar)
* For individual setup: terminal access on the developer's machine

## Setup

### Option A: Deploy via MDM (recommended for teams)

Use this approach to roll out git-ai across your entire engineering organization without requiring action from individual developers.

<Steps>
  <Step title="Download the MDM install script">
    Go to **Data** → **Git attribution** (if it's already connected, open its **Setup** tab), choose **Managed install**, and under **Download install script** download the script for your platform. Weave generates an MDM-safe wrapper (not the raw upstream git-ai installer):

    * **macOS / Linux**: `install.sh`
    * **Windows (incl. WSL)**: `install.ps1`

    <Tip>Always download the latest script before deploying. Weave pins the git-ai release version and updates the wrapper when needed.</Tip>
  </Step>

  <Step title="Deploy via MDM">
    Distribute the downloaded script using your MDM solution:

    | MDM solution | Instructions |
    | - | - |
    | Fleet | Create a policy that runs the script on macOS/Linux hosts |
    | Intune | Add as a shell script (macOS/Linux) or PowerShell script (Windows) in device configuration |
    | Kandji | Add as a custom script in your library |
    | Jamf | Create a policy with the script and scope to target computers |

    The script is idempotent and safe to run multiple times. It requires no user interaction. On macOS, when an MDM tool runs the script as `root`, the wrapper installs git-ai as the logged-in console user and restores ownership of `~/.git-ai` and agent config directories so git-ai works for that developer. On Windows, the script must run in the user's context (it refuses an elevated Administrator shell) and also installs git-ai into any WSL distributions on the machine.

    <Note>See the [important notes on MDM deployment](#mdm-deployment-notes) below for edge cases.</Note>
  </Step>

  <Step title="Verify with a test group">
    Before rolling out to the full organization, deploy to a small test group of active developers first:

    1. Have a test developer generate some AI-assisted code (e.g., use Cursor, Claude Code, or Copilot to write a function)
    2. Have them run `git-ai status` in their terminal — this should show checkpoints indicating which AI tool generated code
    3. Have them commit and push the code
    4. Merge the pull request that contains the commit, then check Weave within a few hours. Attribution metrics only count commits from merged pull requests, and data appears after the next repository sync cycle (runs approximately every 3 hours)
  </Step>

  <Step title="Roll out to all developers">
    Once verified with the test group, expand the MDM deployment to all target machines.
  </Step>
</Steps>

#### MDM deployment notes

<Warning>**Do not substitute the upstream git-ai installer.** Pasting `curl | bash` from the git-ai repo into an MDM tool that runs as `root` leaves `~/.git-ai` and agent config directories root-owned, which breaks git-ai for the developer (for example, SQLite errors like "unable to open database file"). Use the signed installers or the Weave-generated wrapper under **Managed install** on **Data** → **Git attribution**.</Warning>

<Note>**macOS / Linux `~/.gitconfig` ownership:** The Weave wrapper installs as the logged-in user on macOS when MDM runs as `root`, but if your policy still leaves `~/.gitconfig` root-owned, restore ownership after install (for example `chown "$USER" ~/.gitconfig` in Jamf, `$3` is the logged-in username).</Note>

<Note>**Windows elevation:** The Windows wrapper exits if launched from an elevated Administrator shell. Configure your MDM policy to run it in the signed-in user's context.</Note>

### Option B: Individual installation

For single developers or small teams, run the install script directly on each machine.

<Steps>
  <Step title="Download and run the install script">
    Go to **Data** → **Git attribution** (if it's already connected, open its **Setup** tab). Choose **Individual install** and run the **Quick install** command for your platform, or choose **Managed install** and download the script under **Download install script**. To run a downloaded script:

    **macOS / Linux:**

    ```bash theme={null}
    chmod +x install.sh && ./install.sh
    ```

    **Windows (PowerShell, not as Administrator):**

    ```powershell theme={null}
    .\install.ps1
    ```

    The script output will confirm:

    * Whether the binary was installed successfully
    * Where the binary was placed on your `PATH`
    * Which AI tool hooks were detected and configured
  </Step>

  <Step title="Verify installation">
    Generate some AI-assisted code using any supported AI tool, then run:

    ```bash theme={null}
    git-ai status
    ```

    You should see checkpoints listing which AI tool generated code. If the output is empty, see the [troubleshooting section](#troubleshooting) below.
  </Step>

  <Step title="Make a commit and push">
    Commit your changes and push to the remote repository. Weave will pick up the git-ai attribution data on the next repository sync (approximately every 3 hours).
  </Step>
</Steps>

### Video walkthroughs

<Frame caption="Setting up git attribution in Weave (macOS)">
  <video controls className="w-full aspect-video rounded-xl" src="https://mintcdn.com/weave-50313446/G7fjE2xcRBR6g-xj/videos/Setting%20Up%20Git%20Attribution%20in%20Weave.mp4?fit=max&auto=format&n=G7fjE2xcRBR6g-xj&q=85&s=a85dd3534b23c2375692f25eb8a84252" data-path="videos/Setting Up Git Attribution in Weave.mp4" />
</Frame>

<Frame caption="Setting up git attribution in Weave (Windows)">
  <video controls className="w-full aspect-video rounded-xl" src="https://mintcdn.com/weave-50313446/G7fjE2xcRBR6g-xj/videos/Git%20AI%20Installation%20on%20Windows%20Part%201.mp4?fit=max&auto=format&n=G7fjE2xcRBR6g-xj&q=85&s=a8f4c3fdb38f106bceff8bfb8c578771" data-path="videos/Git AI Installation on Windows Part 1.mp4" />
</Frame>

## Verifying data in Weave

After git-ai is installed and a developer has pushed at least one commit, there is a short delay before data appears in Weave. The repository clone job runs approximately every 3 hours, and attribution metrics include a commit only after its pull request is merged.

To confirm everything is working end-to-end:

1. A developer with git-ai installed generates AI-assisted code
2. They commit, push to a repository connected to Weave, and merge the pull request
3. Within a few hours, AI attribution data appears in the Weave dashboard under the relevant metrics

<Note>Even commits made without AI assistance will be picked up by git-ai — it records git notes for every commit. You don't need to use an AI tool to verify the binary is working; any commit will do.</Note>

## Metrics enabled

Git attribution enhances the accuracy of:

* **[AI code LOC](/metrics/ai-code-loc)** — Precise line-level AI attribution
* **[AI output percentage](/metrics/ai-output-percentage)** — Accurate AI contribution ratios

Git attribution works alongside AI tool telemetry and plugins without double counting. When git attribution has data for a developer's AI tool on a given day, it replaces that tool's telemetry-based AI code estimate for that day instead of adding to it. See [choosing a Claude Code connection](/ai-tools/claude-code#choosing-a-connection).

## Troubleshooting

<AccordionGroup>
  <Accordion icon="download" title="Binary not installed correctly">
    The most common issue is the git-ai binary not being present or not being on the developer's `PATH`.

    **How to check:**

    ```bash theme={null}
    which git-ai
    ```

    If this returns nothing, the binary wasn't installed or isn't on the `PATH`.

    **If installed manually:** Re-run the install script and review its output — it will report whether installation succeeded and where the binary was placed.

    **If deployed via MDM:** Check your MDM solution's deployment logs for errors during script execution. Common causes:

    * The script failed silently due to permissions issues
    * The target directory wasn't writable
    * A prior version was partially installed
  </Accordion>

  <Accordion icon="plug" title="AI tool hooks not configured">
    Even if the binary is installed, git-ai needs hooks configured in each AI coding tool to detect AI-generated code.

    **How to check:**

    1. Generate some AI-assisted code using your AI tool of choice
    2. Run `git-ai status`
    3. If you see checkpoints showing the tool and generated code — hooks are working
    4. If the output is empty — hooks aren't configured for that tool

    **If installed manually:** Re-run the install script. It will detect AI tools on the machine and configure hooks for each one. The script output lists exactly which tools were detected and configured.

    **If deployed via MDM:** The install script configures hooks for all AI tools it detects at install time. If a developer installs a new AI tool after git-ai was deployed, its hooks may not be configured yet. Re-run the install script to configure them right away.
  </Accordion>

  <Accordion icon="clock" title="Data not appearing in Weave">
    After pushing a commit with git-ai notes, there's a delay before data shows up in Weave.

    **Expected timeline:** Data appears within approximately 3 hours of the pull request merging, as Weave's repository clone job runs on this cycle and attribution metrics count commits from merged pull requests.

    **If data still isn't appearing after several hours:**

    1. Verify the repository is connected to Weave (check **Data** → **Repositories**)
    2. Confirm the developer actually pushed the commit (not just committed locally) and that its pull request is merged
    3. Check that `git-ai status` shows checkpoints on the developer's machine
    4. Contact [support@workweave.ai](mailto:support@workweave.ai) if the issue persists
  </Accordion>

  <Accordion icon="lock" title="Git config broken after MDM deployment">
    If developers report that their personal git configuration (aliases, user name, signing keys, etc.) stopped working after an MDM deployment, `~/.gitconfig` may be root-owned.

    **How to check:**

    ```bash theme={null}
    ls -la ~/.gitconfig
    ```

    If the file is owned by `root` instead of the developer's username, this is the issue:

    ```
    -rw-------  1 root  staff  940 May 20 15:43 /Users/jane/.gitconfig
    ```

    **Fix for affected machines:**

    ```bash theme={null}
    sudo chown $(id -un) ~/.gitconfig
    chmod 600 ~/.gitconfig
    ```

    **Prevent for future deployments:** Use the Weave-generated MDM wrapper (not the upstream git-ai installer) and add a post-install ownership fix if needed. See [MDM deployment notes](#mdm-deployment-notes).
  </Accordion>

  <Accordion icon="windows" title="Windows + WSL issues">
    The Weave Windows wrapper installs git-ai in the native Windows environment **and** runs the Linux installer inside each WSL distribution it finds. If a developer's WSL distro was added after deployment, re-run the install script or have them run the **macOS / Linux / Windows (WSL)** **Quick install** command (under **Individual install** on **Data** → **Git attribution**) inside WSL.
  </Accordion>

  <Accordion icon="users" title="Works for some developers but not others">
    When git-ai works for part of the team but not everyone, the issue is usually environment differences.

    **Diagnostic steps:**

    1. **Same OS, different results?** Check if the affected developers have a different shell configuration, `PATH` setup, or security software that might interfere
    2. **Different OS?** If it works on macOS but not Windows (or vice versa), the install script for that platform may have an issue — check MDM logs for the failing platform
    3. **WSL users?** Developers using WSL need a separate Linux installation inside WSL (see above)
    4. **New AI tool?** If git-ai was deployed before the developer installed their AI coding tool, the hooks may not be configured yet, so re-run the install script

    For persistent issues, have the affected developer run `git-ai status` after generating AI code and share the output with your IT team or [support@workweave.ai](mailto:support@workweave.ai).
  </Accordion>

  <Accordion icon="building" title="MDM deployment not working for anyone">
    If git-ai isn't working for any developer after an MDM deployment, the install script likely failed during distribution.

    **Steps to diagnose:**

    1. Check your MDM solution's execution logs for the install script — look for errors or non-zero exit codes
    2. Verify the script was distributed to the correct device groups
    3. Confirm the script has execution permissions
    4. Try running the script manually on one machine to see its output — this will clearly indicate whether the binary was installed and which hooks were configured
    5. Ensure you're deploying the latest version of the install script from Weave
  </Accordion>

  <Accordion icon="rotate" title="One AI tool tracked but not another">
    If git-ai tracks code from one AI tool (e.g., Cursor) but not another (e.g., Claude Code), the hooks for the missing tool aren't configured.

    **How to fix:**

    1. Re-run the install script — it will detect all AI tools currently installed and configure hooks
    2. If the tool was installed after git-ai, its hooks may not be configured yet, because the install script configures hooks for tools present at install time
    3. Run `git-ai status` after generating code with the missing tool to confirm whether it's now tracked
  </Accordion>
</AccordionGroup>

## FAQ

<AccordionGroup>
  <Accordion title="How long until data appears in Weave after installation?">
    After a developer installs git-ai and pushes a commit, Weave picks up the data on the next repository sync cycle (approximately every 3 hours), and attribution metrics include the commit once its pull request is merged. In the meantime, you can verify locally that git-ai is working by running `git-ai status`.
  </Accordion>

  <Accordion title="Does the developer need to use an AI tool to test the installation?">
    No. Git-ai records notes on every commit, even those made without AI assistance. Any commit and push will confirm the binary is working. However, to verify that **AI tool hooks** are configured correctly, you should generate some AI-assisted code and check `git-ai status` for checkpoints.
  </Accordion>

  <Accordion title="Can we test with a small group before full rollout?">
    Yes, and this is recommended. Deploy to a small test group of active developers first, verify data appears in Weave, then expand the MDM deployment to the full organization.
  </Accordion>

  <Accordion title="What happens if a developer already has git-ai and we re-run the script?">
    The install script is idempotent — running it again is safe and will update the binary and re-configure hooks without disrupting anything.
  </Accordion>

  <Accordion title="Does git-ai affect normal git operations?">
    No. The git-ai binary is a transparent wrapper — it passes all commands through to the real `git` binary. Developers won't notice any difference in their normal git workflow.
  </Accordion>
</AccordionGroup>

## Data privacy

Git attribution stores metadata about AI tool usage in git notes, including:

* Which AI tool was used
* Number of AI-assisted lines per commit
* Schema version information
* File paths indicating which files had AI-assisted changes
* Conversation transcripts (prompts and assistant responses)

This data is stored locally in your git repository's notes. Weave reads this metadata during repository sync to extract tool attribution and line counts, but does not persist the conversation transcripts or source code content.

## Related

* [AI output attribution](/analysis/ai-output-attribution) — How Weave calculates AI attribution
* [Claude Code](/ai-tools/claude-code) — CLI-based AI assistant
* [Cline](/ai-tools/cline) — VS Code extension for AI coding


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.