@@ -143,7 +143,7 @@ export class ExplorerCommands extends Disposable {
143143 if ( ! ( node instanceof BranchHistoryNode ) ) return ;
144144
145145 const command = `checkout ${ node . branch . name } ` ;
146- this . sendTerminalCommand ( command ) ;
146+ this . sendTerminalCommand ( command , node . branch . repoPath ) ;
147147 }
148148
149149 async terminalCreateBranch ( node : ExplorerNode ) {
@@ -157,7 +157,7 @@ export class ExplorerCommands extends Disposable {
157157 if ( name === undefined || name === '' ) return ;
158158
159159 const command = `branch ${ node . branch . remote ? '-t ' : '' } ${ name } ${ node . branch . name } ` ;
160- this . sendTerminalCommand ( command ) ;
160+ this . sendTerminalCommand ( command , node . branch . repoPath ) ;
161161 }
162162
163163 terminalDeleteBranch ( node : ExplorerNode ) {
@@ -166,52 +166,48 @@ export class ExplorerCommands extends Disposable {
166166 const command = node . branch . remote
167167 ? `push ${ node . branch . remote } :${ node . branch . name } `
168168 : `branch -d ${ node . branch . name } ` ;
169- this . sendTerminalCommand ( command ) ;
169+ this . sendTerminalCommand ( command , node . branch . repoPath ) ;
170170 }
171171
172172 terminalRebaseBranchToRemote ( node : ExplorerNode ) {
173- let command : string ;
174173 if ( node instanceof BranchHistoryNode ) {
175174 if ( ! node . branch . current || ! node . branch . tracking ) return ;
176175
177- command = `rebase -i ${ node . branch . tracking } ` ;
176+ const command = `rebase -i ${ node . branch . tracking } ` ;
177+ this . sendTerminalCommand ( command , node . branch . repoPath ) ;
178178 }
179179 else if ( node instanceof StatusUpstreamNode ) {
180- command = `rebase -i ${ node . status . upstream } ` ;
180+ const command = `rebase -i ${ node . status . upstream } ` ;
181+ this . sendTerminalCommand ( command , node . status . repoPath ) ;
181182 }
182- else {
183- return ;
184- }
185-
186- this . sendTerminalCommand ( command ) ;
187183 }
188184
189185 terminalSquashBranchIntoCommit ( node : ExplorerNode ) {
190186 if ( ! ( node instanceof BranchHistoryNode ) ) return ;
191187
192188 const command = `merge --squash ${ node . branch . name } ` ;
193- this . sendTerminalCommand ( command ) ;
189+ this . sendTerminalCommand ( command , node . branch . repoPath ) ;
194190 }
195191
196192 terminalRebaseCommit ( node : ExplorerNode ) {
197193 if ( ! ( node instanceof CommitNode ) ) return ;
198194
199195 const command = `rebase -i ${ node . commit . sha } ^` ;
200- this . sendTerminalCommand ( command ) ;
196+ this . sendTerminalCommand ( command , node . commit . repoPath ) ;
201197 }
202198
203199 terminalResetCommit ( node : ExplorerNode ) {
204200 if ( ! ( node instanceof CommitNode ) ) return ;
205201
206202 const command = `reset --soft ${ node . commit . sha } ^` ;
207- this . sendTerminalCommand ( command ) ;
203+ this . sendTerminalCommand ( command , node . commit . repoPath ) ;
208204 }
209205
210206 terminalRemoveRemote ( node : ExplorerNode ) {
211207 if ( ! ( node instanceof RemoteNode ) ) return ;
212208
213209 const command = `remote remove ${ node . remote . name } ` ;
214- this . sendTerminalCommand ( command ) ;
210+ this . sendTerminalCommand ( command , node . remote . repoPath ) ;
215211 }
216212
217213 private ensureTerminal ( ) : Terminal {
@@ -231,14 +227,14 @@ export class ExplorerCommands extends Disposable {
231227 return this . _terminal ;
232228 }
233229
234- private sendTerminalCommand ( command : string ) {
230+ private sendTerminalCommand ( command : string , cwd : string ) {
235231 // let git = GitService.getGitPath();
236232 // if (git.includes(' ')) {
237233 // git = `"${git}"`;
238234 // }
239235
240236 const terminal = this . ensureTerminal ( ) ;
241237 terminal . show ( false ) ;
242- terminal . sendText ( `git ${ command } ` , false ) ;
238+ terminal . sendText ( `git -C ${ cwd } ${ command } ` , false ) ;
243239 }
244240}
0 commit comments