gitbutlerapp/gitbutler · error
Failed to create a new commit
Error message
Failed to create a new commit
What it means
Thrown by StackDzHandler.ondropChangeData in stackDropHandler.ts after calling macros.createNewStackAndCommit() for a drop with selectionId.type === "commit": the macro reported no newCommit in its outcome, meaning the underlying stack/commit creation mutation did not produce the commit the drop needs as its destination.
Solutions
- Check the backend logs / toast output from createNewStackAndCommit for the underlying mutation failure (hooks, lock file, conflicts)
- Resolve any git-level blockers (index.lock, pre-commit hook failures, merge conflicts) and retry the drop
- Inspect macros.createNewStackAndCommit to confirm it surfaces errors instead of returning an outcome without newCommit
- Retry the operation after refreshing workspace/stack state
Defensive patterns
Strategy: try-catch
Try / catch
try {
await handler.ondropChangeData(data);
} catch (e) {
if (e instanceof Error && e.message === 'Failed to create a new commit') {
toast.error('Could not create the destination commit; check hooks, conflicts and repository state, then retry');
} else throw e;
} Prevention
- Ensure no index.lock, failing hooks, or unresolved conflicts before dropping
- Check createNewStackAndCommit's outcome/errors before consuming newCommit
- Retry after refreshing workspace state if the mutation raced
- Monitor backend logs for the underlying stack-service failure
When it happens
Trigger: createNewStackAndCommit() returns outcome.newCommit === null/undefined — e.g. the backend stack creation or commit mutation failed silently, the workspace had no assignable changes, or the dryRun/apply path produced no commit while the caller assumed success.
Common situations: Repository in a state blocking commit creation (hooks failing, index lock, unresolved conflicts); backend service error swallowed by the macro returning an outcome without newCommit; racing mutations where the stack was rewritten between creation and commit.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- Aborting due to empty branch name
- Ad-hoc (single-branch) branch moves are not supported…
- An octopus merge commits must have at least two parents
- another pre-commit hook is already using the repository…
- askpass broker must be initialized
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/60c1f5698ea06238.
Report an issue: GitHub.
Appendix: source
Thrown at apps/desktop/src/lib/dragging/dropHandlers/stackDropHandler.ts:85
return true;
}
accepts(data: unknown) {
return (
this.acceptsChangeDropData(data) ||
this.acceptsBranchDropData(data) ||
this.acceptsHunkDropData(data) ||
this.acceptsCommitDropData(data)
);
}
async ondropChangeData(data: ChangeDropData) {
switch (data.selectionId.type) {
case "commit": {
const { stack, outcome, branchName } = await this.macros.createNewStackAndCommit();
if (!outcome.newCommit) {
throw new Error("Failed to create a new commit");
}
const sourceStackId = data.stackId;
const sourceCommitId = data.selectionId.commitId;
if (sourceStackId) {
const diffSpec = changesToDiffSpec(await data.treeChanges());
await this.macros.moveChangesToNewCommit(
stack.id,
outcome.newCommit,
sourceStackId,
sourceCommitId,
branchName,
diffSpec,
);
} else {
// Should not happen, but just in case
throw new Error("Change drop data must specify the source stackId");
}View on GitHub (pinned to 58e5313667)