You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
When running examples/merge-cleanly.js, the following error is thrown by index.write():
Uncaught Error: Failed to write index: The index is in-memory only
Either index.write() or the example is broken.
@highco I ran into this same issue and ended up solving by using the Merge.merge function instead of Merge.commits. One problem that took me a while to track down is that you need to specify Checkout.STRATEGY.FORCE (or some other non-default strategy) or else it won't change your working directory you'll end up with a completely empty merge commit.
Here's a code snippet that hopefully is helpful:
asyncfunctioncreateMergeCommit(repo,otherCommit,mergeMessage){constannotatedCommit=awaitnodegit.AnnotatedCommit.lookup(repo,otherCommit.id());awaitnodegit.Merge.merge(repo,annotatedCommit,null,{checkoutStrategy: nodegit.Checkout.STRATEGY.FORCE,});constindex=awaitrepo.refreshIndex();if(index.hasConflicts()){thrownewCLIError('Unexpected conflict when creating merge commit.');}awaitindex.write();consttreeOid=awaitindex.writeTree();awaitrepo.createCommit('HEAD',repo.defaultSignature(),repo.defaultSignature(),mergeMessage,treeOid,[awaitrepo.getHeadCommit(),otherCommit]);repo.stateCleanup();}
Activity
alangpierce commentedon Oct 22, 2016
@highco I ran into this same issue and ended up solving by using the
Merge.mergefunction instead ofMerge.commits. One problem that took me a while to track down is that you need to specifyCheckout.STRATEGY.FORCE(or some other non-default strategy) or else it won't change your working directory you'll end up with a completely empty merge commit.Here's a code snippet that hopefully is helpful:
Full example here:
https://github.com/alangpierce/bulk-decaffeinate/blob/master/src/land.js