Getting started
Install git-edge and perform your first object-level three-way merge.
Install
npm install git-edge isomorphic-gitisomorphic-git and git-fs-s3 (≥ 0.8) are peer dependencies — install
them yourself; threeWayMerge stores its objects through git-fs-s3's
withPackedWrites. git-edge works with any isomorphic-git-compatible
fs, including plain node:fs, not only git-fs-s3's.
Quick start
-
Build the
{ fs, gitdir, cache? }shape isomorphic-git itself expects — any compatiblefsworks,node:fshere.import fs from 'node:fs'; const repo = { fs, gitdir: '/repo.git', cache: {} }; -
Merge one ref into another.
threeWayMergeresolves both refs, takes the fast-forward shortcut when possible, and otherwise merges at the tree level — no worktree involved at any point.import { threeWayMerge, GitMergeConflictError } from 'git-edge'; try { const { commitOid } = await threeWayMerge(repo, 'feature', 'main', { authorName: 'Ada', authorEmail: 'ada@example.com', }); console.log('merged:', commitOid); } catch (err) { if (err instanceof GitMergeConflictError) { console.log('conflicts in:', err.conflictingPaths); } else { throw err; } }
With git-fs-s3
Same call, backed by object storage instead of local disk — this is the pairing git-edge was extracted alongside.
import git from 'isomorphic-git';
import { createGitFs, MemoryObjectStore } from 'git-fs-s3';
import { threeWayMerge } from 'git-edge';
const fs = createGitFs(new MemoryObjectStore());
const repo = { fs, gitdir: '/repo.git', cache: {} };
await git.init({ ...repo, dir: repo.gitdir, bare: true });
// ... commits land on "feature" and "main" via git-fs-s3's fs ...
await threeWayMerge(repo, 'feature', 'main');Neither package imports the other — they just agree on the same { fs, gitdir, cache? } shape. Swap in any isomorphic-git-compatible fs and
threeWayMerge works unchanged.
Next steps
- Reading the same repo's objects repeatedly (a commit list, a rendered diff)? See the parsed-object cache guide.
- Running many operations against the same repo in one process? See Repo cache for isomorphic-git's own packfile cache.
git-edge
High-level edge-compatible git operations on top of isomorphic-git — an object-level three-way merge that never needs a worktree, a parsed-object cache, and per-repo packfile-cache management.
Semantics & limitations
What threeWayMerge does and doesn't guarantee, and where the other helpers stop.