Skip to main content
To share a code graph with your team, commit graphify-out/graph.json and let git merge it with Graphify’s union merge driver instead of as text. Every clone then starts with the same map, and two branches that both changed the graph merge without a conflict. This recipe sets that up and adds attribution for sources teammates add.

What you’ll build

  • A committed graph.json that matches each commit’s code.
  • A .gitattributes rule and a merge driver so merges union the graph.
  • A pre-commit hook that rebuilds and stages the graph.
  • Tagged sources, so you know who added which document.

Setup

Step 1: Track only the graph

Other files in graphify-out/ are rebuilt locally. Track just the graph. In .gitignore:
Review the graph before the first commit. It holds names and paths taken from your source.

Step 2: Mark the graph and register the merge driver

In .gitattributes:
linguist-generated=true collapses the file in GitHub pull requests. -diff keeps it out of git diff. merge=graphify names the driver. Register the driver in each clone. graphify hook install does this too, but graphify hook uninstall removes it again along with the .gitattributes entry, so with the pre-commit hook in Step 3 register it by hand: point it at the Python that Graphify runs in, so merges also work in GUI git clients where graphify isn’t on PATH.
The driver takes the base, current and other versions, writes the union of nodes and edges back to the current file, and exits 1 on a corrupt or oversized graph so git shows a conflict instead of accepting it.

Step 3: Rebuild before each commit

graphify hook install rebuilds after each commit, which leaves the rebuilt graph as an uncommitted change. If you commit the graph, use a pre-commit hook instead. Add this to .git/hooks/pre-commit (with #!/bin/sh first and chmod +x):
PYTHONHASHSEED=0 keeps clustering deterministic, so community ids don’t churn between machines.

Step 4: Merge two graphs by hand

When you need to combine graphs outside git, for example from two services:
For a standing cross-repo graph, use graphify global add graphify-out/graph.json --as my-service in each repository, then graphify global list.

Step 5: Tag who added a source

When teammates add docs, papers or pages to the graph, record who added them:
add saves the page to ./raw and updates the graph. The saved file’s frontmatter records the contributor (falling back to the author), so the graph can trace each source back to a person.

When it goes wrong

A merge stops with a conflict in graph.json. The driver isn’t registered in this clone, or it rejected a corrupt file. Check git config merge.graphify.driver. To recover, rebuild:
Every commit shows a huge graph diff. Since Graphify 0.9.86, graph.json is one line of compact JSON, so a rebuilt graph shows as one changed line. Upgrade if you see more. CI commits fail the hook. Install Graphify in CI, or set GRAPHIFY_SKIP_HOOK=1 for those commits.

Production patterns

  • Commit hooks in .githooks/ and run git config core.hooksPath .githooks in each clone so everyone shares them.
  • Run graphify update . after a branch switch to refresh the untracked report and HTML.
  • In Graphify, the hosted product, the graph lives on our servers and every teammate’s agent reads the same one over MCP. There’s nothing to commit.

Complete example

What you built

Your team shares one graph through git. It merges without conflicts, rebuilds with each commit, and records who added each source.

Next steps

Team workflows

The full reference for committing and merging the graph.

Keep docs in sync

Rebuild the graph and wiki on every commit.

Try it in Graphify

We build and host the graph for you. Start with a 14-day Pro trial, then keep up to 3 repositories on Free. No card required.