@@ -259,6 +259,14 @@ def _connect_local_repo_to_managed_remote(
259259 except GitManagerError as e :
260260 raise Exception (f"Failed to set remote: { e .message } " ) from e
261261
262+ # Sync .gitignore before committing so it's included in the push
263+ self .stdout .write (f" Syncing .gitignore contents..." )
264+ try :
265+ sync_gitignore_contents (dbt_repo_dir )
266+ except Exception as err :
267+ logger .error (f"Failed to sync .gitignore contents: { err } " )
268+ self .stdout .write (f" Warning: Failed to sync .gitignore: { err } " )
269+
262270 # Commit any uncommitted changes (UI orgs may have model changes not yet committed)
263271 self .stdout .write (f" Committing any uncommitted changes..." )
264272 try :
@@ -303,15 +311,5 @@ def _connect_local_repo_to_managed_remote(
303311 # Set up Prefect blocks (dual storage - AWS + Prefect)
304312 update_github_pat_storage (org , remote_repo_url , access_token )
305313
306- self .stdout .write (f" Syncing .gitignore contents..." )
307-
308- # Sync gitignore contents
309- try :
310- sync_gitignore_contents (dbt_repo_dir )
311- except Exception as err :
312- logger .error (f"Failed to sync .gitignore contents: { err } " )
313- # Don't fail the migration for gitignore issues
314- self .stdout .write (f" Warning: Failed to sync .gitignore: { err } " )
315-
316314 logger .info (f"Connected git remote for org { org .slug } : { remote_repo_url } " )
317315 self .stdout .write (f" ✅ Local repository successfully connected to managed remote" )
0 commit comments