@@ -93,6 +93,11 @@ func (ws *GitInitializer) Run(ctx context.Context, mappings []archive.IDMapping)
93
93
log .WithError (err ).WithField ("location" , ws .Location ).Error ("cannot configure fecth behavior" )
94
94
}
95
95
96
+ err = ws .Git (ctx , "config" , "--replace-all" , "checkout.defaultRemote" , "origin" )
97
+ if err != nil {
98
+ log .WithError (err ).WithField ("location" , ws .Location ).Error ("cannot configure checkout defaultRemote" )
99
+ }
100
+
96
101
return nil
97
102
}
98
103
onGitCloneFailure := func (e error , d time.Duration ) {
@@ -176,7 +181,12 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
176
181
return err
177
182
}
178
183
179
- if err := ws .Git (ctx , "switch" , "--track" , "-C" , ws .CloneTarget ); err != nil {
184
+ if err := ws .Git (ctx , "fetch" , "origin" , ws .CloneTarget ); err != nil {
185
+ log .WithError (err ).WithField ("remoteURI" , ws .RemoteURI ).WithField ("branch" , ws .CloneTarget ).Error ("Cannot fetch remote branch" )
186
+ return err
187
+ }
188
+
189
+ if err := ws .Git (ctx , "checkout" , "-B" , ws .CloneTarget , "--track" ); err != nil {
180
190
log .WithError (err ).WithField ("remoteURI" , ws .RemoteURI ).WithField ("branch" , ws .CloneTarget ).Error ("Cannot fetch remote branch" )
181
191
return err
182
192
}
@@ -194,7 +204,7 @@ func (ws *GitInitializer) realizeCloneTarget(ctx context.Context) (err error) {
194
204
}
195
205
196
206
// checkout specific commit
197
- if err := ws .Git (ctx , "switch " , "--track " , "-C" , ws .CloneTarget ); err != nil {
207
+ if err := ws .Git (ctx , "checkout " , "-B " , ws .CloneTarget , "--track" ); err != nil {
198
208
return err
199
209
}
200
210
default :
0 commit comments