Git subtree merge changes project ID (making history inaccessible) #8507

Open
opened 2026-02-16 18:10:09 -05:00 by yindo · 1 comment
Owner

Originally created by @michalrus on GitHub (Feb 4, 2026).

Originally assigned to: @thdxr on GitHub.

Description

Since the project ID is based on the initial commit:

git rev-list --max-parents=0 --all

… once you perform a Git subtree merge, to merge a smaller repository as a subdirectory of the larger monorepo, it will potentially change the project ID (depending on which repository is newer).

The new project ID is then also the initial commit of the smaller repository, so now you share session history between the smaller repository and the monorepo, after the subtree merge.

I understand how and why this occurs, but it’s a little confusing. Perhaps if there were more than one root commit, something else should happen.

Plugins

none

OpenCode version

1.1.47

Steps to reproduce

  1. Open a project, start a session.
  2. Now either:
    • merge another repo as a subdirectory of this one: git subtree add --prefix=subdir other-remote other-branch,
    • or just add another root to the commit tree: git switch --orphan orphan and commit something.
  3. Reopen the project – the session history is gone.

Screenshot and/or share link

No response

Operating System

Linux

Terminal

Alacritty

Originally created by @michalrus on GitHub (Feb 4, 2026). Originally assigned to: @thdxr on GitHub. ### Description Since the project ID is based on the initial commit: ``` git rev-list --max-parents=0 --all ``` … once you perform a Git subtree merge, to merge a smaller repository as a subdirectory of the larger monorepo, it will potentially change the project ID (depending on which repository is newer). The new project ID is then also the initial commit of the smaller repository, so now you share session history between the smaller repository and the monorepo, after the subtree merge. I understand how and why this occurs, but it’s a little confusing. Perhaps if there were more than one root commit, something else should happen. ### Plugins _none_ ### OpenCode version 1.1.47 ### Steps to reproduce 1. Open a project, start a session. 2. Now either: - merge another repo as a subdirectory of this one: `git subtree add --prefix=subdir other-remote other-branch`, - or just add another root to the commit tree: `git switch --orphan orphan` and commit something. 3. Reopen the project – the session history is gone. ### Screenshot and/or share link _No response_ ### Operating System Linux ### Terminal Alacritty
yindo added the bug label 2026-02-16 18:10:09 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 4, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #6696: [BUG]: Project ID collision when repos cloned from same source share sessions - describes the same root cause where the project ID is derived from the initial commit hash, leading to collisions and shared session history

Feel free to ignore if this doesn't address your specific case.

@github-actions[bot] commented on GitHub (Feb 4, 2026): This issue might be a duplicate of existing issues. Please check: - #6696: [BUG]: Project ID collision when repos cloned from same source share sessions - describes the same root cause where the project ID is derived from the initial commit hash, leading to collisions and shared session history Feel free to ignore if this doesn't address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8507