# How to Uninstall the Graph Module from Hivemind: Complete Guide

> Uninstall the graph module from Hivemind easily. Learn the simple command to remove the Git post-commit hook safely.

- Repository: [Activeloop/hivemind](https://github.com/activeloopai/hivemind)
- Tags: how-to-guide
- Published: 2026-06-11

---

**The graph module in Hivemind is implemented as a managed Git post-commit hook, and you can uninstall it by running `hivemind graph uninstall`, which executes the `uninstallPostCommitHook` function to safely remove the hook while preserving other custom scripts.**

The Hivemind graph feature tracks repository evolution through an automated Git integration. When you need to remove this functionality, the process involves safely detaching the managed hook from your repository's Git configuration without disrupting existing workflows. This guide covers both CLI and programmatic approaches to uninstall the graph module from Hivemind, referencing the actual source implementation in the `activeloopai/hivemind` repository.

## Using the CLI Command

The fastest way to uninstall the graph module is through the Hivemind command-line interface. The CLI entry point resides in [`src/commands/graph.ts`](https://github.com/activeloopai/hivemind/blob/main/src/commands/graph.ts), which parses the `graph uninstall` subcommand and delegates to `runUninstallCommand`.

### Basic Usage

Run the uninstall command from within your repository root:

```bash
hivemind graph uninstall

```

This command locates the Git post-commit hook in your current working directory and removes the Hivemind-managed block if present.

### Specifying a Custom Repository Path

If you need to target a repository outside your current directory, use the `--cwd` flag:

```bash
hivemind graph uninstall --cwd /path/to/my/project

```

## How the Uninstall Process Works

The uninstallation logic is implemented in [`src/graph/git-hook-install.ts`](https://github.com/activeloopai/hivemind/blob/main/src/graph/git-hook-install.ts) within the `uninstallPostCommitHook` function. Understanding this process helps troubleshoot edge cases and verify successful removal.

### Hook Location and Detection

The function first computes the absolute path to your repository's `post-commit` hook using `postCommitHookPath`, which respects the Git `core.hooksPath` configuration if set. If no hook file exists at that location, the operation returns a `no-hook` status and exits silently.

### Ownership Verification

Before modifying any files, the system verifies that the hook was actually installed by Hivemind. The `containsOurMarkers` function checks for both `HOOK_BEGIN_MARKER` and `HOOK_END_MARKER` sentinel comments that surround the Hivemind block. If these markers are absent, the uninstall aborts with a `not-ours` status and prints a helpful hint to prevent accidental deletion of user-written hooks.

### Safe Removal Logic

The uninstallation handles three distinct scenarios based on hook content:

1. **Dedicated Hivemind file**: If the hook contains only the Hivemind block (shebang plus whitespace), the entire file is deleted.
2. **Mixed content**: If the file contains other user-written scripts, `stripOurBlock` removes only the content between the Hivemind markers, preserving the rest of the script.
3. **Foreign hook**: If the markers are missing, the operation refuses to proceed to prevent data loss.

## Programmatic Usage

You can invoke the uninstall routine directly from Node.js applications without spawning shell processes. Import the function from `@deeplake/hivemind` (or the appropriate package scope):

```typescript
import { uninstallPostCommitHook } from "@deeplake/hivemind/src/graph/git-hook-install.js";

const cwd = "/path/to/repo";
const result = uninstallPostCommitHook(cwd);

switch (result.kind) {
  case "removed":
    console.log(`Hook removed (whole file deleted: ${result.wholeFileDeleted})`);
    break;
  case "no-hook":
    console.log("No post-commit hook found.");
    break;
  case "not-ours":
    console.error(`Hook not managed by Hivemind: ${result.hint}`);
    break;
}

```

This approach provides fine-grained control and allows you to handle specific return states programmatically.

## Cleaning Up Graph Snapshots

**Important**: The uninstall command removes only the Git hook integration. Your persisted graph data remains stored in `~/.hivemind/graphs/<repo-key>/` and must be deleted manually if you want complete removal:

```bash

# Remove snapshots for the current repository

rm -rf ~/.hivemind/graphs/$(hivemind graph key)

```

Replace the path with your specific repository key if targeting a different project.

## Summary

- Run `hivemind graph uninstall` to remove the managed Git post-commit hook from your repository.
- The uninstaller verifies ownership via `HOOK_BEGIN_MARKER` and `HOOK_END_MARKER` before modifying any files.
- If the hook contains only Hivemind content, the file is deleted; otherwise, only the Hivemind block is stripped via `stripOurBlock`.
- Call `uninstallPostCommitHook` programmatically from [`src/graph/git-hook-install.ts`](https://github.com/activeloopai/hivemind/blob/main/src/graph/git-hook-install.ts) for custom automation.
- Graph snapshots persist in `~/.hivemind/graphs/` after uninstallation and require manual deletion.

## Frequently Asked Questions

### Does uninstalling the graph module delete my graph data?

No. The `uninstallPostCommitHook` function in [`src/graph/git-hook-install.ts`](https://github.com/activeloopai/hivemind/blob/main/src/graph/git-hook-install.ts) only removes the Git integration hook. Your stored graph snapshots remain in `~/.hivemind/graphs/<repo-key>/` and remain accessible if you reinstall the module later.

### What happens if my post-commit hook contains other custom scripts?

The uninstaller detects mixed content using `containsOurMarkers` and calls `stripOurBlock` to surgically remove only the Hivemind-specific section between the markers. If the file contains other user-written code, it preserves that content and keeps the file intact.

### Can I reinstall the graph module after uninstalling?

Yes. Uninstallation is non-destructive to your repository configuration. You can run `hivemind graph install` at any time to re-attach the post-commit hook, provided you have not manually deleted the graph snapshots stored in `~/.hivemind/graphs/`.

### Where is the uninstall logic implemented in the source code?

The core logic resides in [`src/graph/git-hook-install.ts`](https://github.com/activeloopai/hivemind/blob/main/src/graph/git-hook-install.ts) within the `uninstallPostCommitHook` function. The CLI dispatcher that handles the `graph uninstall` subcommand is located in [`src/commands/graph.ts`](https://github.com/activeloopai/hivemind/blob/main/src/commands/graph.ts), and the top-level command registration happens in [`src/cli/index.ts`](https://github.com/activeloopai/hivemind/blob/main/src/cli/index.ts).