@@ -114,15 +114,16 @@ export class RepoStorageBackend implements StorageBackend {
114114 const fileCount = Object . keys ( files ) . length ;
115115 const startTime = Date . now ( ) ;
116116
117- // Get current HEAD commit SHA
117+ // Get current HEAD commit and its tree SHA
118118 const headSha = await this . getHeadSha ( ) ;
119+ const baseTreeSha = await this . getCommitTreeSha ( headSha ) ;
119120
120121 // Build tree entries with inline content (no separate blob creation needed)
121122 const treeEntries = this . buildTreeEntries ( files ) ;
122123 this . logProgress ( `Prepared ${ String ( treeEntries . length ) } tree entries` ) ;
123124
124125 // Create new tree with base_tree for incremental update
125- const newTreeSha = await this . createTree ( treeEntries , headSha ) ;
126+ const newTreeSha = await this . createTree ( treeEntries , baseTreeSha ) ;
126127
127128 // Create commit
128129 const message = `Sync update: ${ String ( fileCount ) } files` ;
@@ -383,6 +384,16 @@ export class RepoStorageBackend implements StorageBackend {
383384 return data . object . sha ;
384385 }
385386
387+ /** Get the tree SHA for a commit */
388+ private async getCommitTreeSha ( commitSha : string ) : Promise < string > {
389+ const res = await this . fetch ( `/git/commits/${ commitSha } ` ) ;
390+ if ( ! res . ok ) {
391+ throw new RepoApiError ( 'Failed to get commit tree' , res . status ) ;
392+ }
393+ const data = ( await res . json ( ) ) as { tree : { sha : string } } ;
394+ return data . tree . sha ;
395+ }
396+
386397 /**
387398 * Build tree entries with inline content.
388399 * Uses GitHub's ability to accept `content` directly instead of blob SHA,
0 commit comments