How to export a Lovable project to GitHub
By Yash Garg · · 6 min read
You can export your Lovable project to a private GitHub repository for free using two-way Git sync. A widespread misconception claims that exporting your codebase requires an active paid subscription. While one-click direct ZIP downloads do require a paid plan according to Lovable's code editor documentation, repository synchronization is available across all plans based on Lovable's Git sync overview.
Lovable connects to exactly one Git repository at a time and cannot link to an existing external repository with prior commit history. If you need version control, local development capabilities, or a safe deployment pipeline for a client website, connecting GitHub gives you complete ownership of your application code without platform lock-in.
Step-by-step guide to connect and export to GitHub
Setting up repository export requires a few deliberate administrative decisions, especially when building sites for agency clients. Authenticate using a dedicated company GitHub organization instead of a personal profile. Using an organization ensures your team retains repository access and ownership even if individual developer seats change.
Follow these steps to connect your workspace:
- You can also click the GitHub icon directly in the editor toolbar.
- Click Connect GitHub to install and authorize the official Lovable GitHub App for your user account or target organization.
- Review the requested permissions. The application requests Administration:write access, which is required solely because Lovable automates the creation of the target repository under GitHub's permission model.
- Trigger the initial export by clicking Connect in the integration panel. Lovable immediately provisions a new private repository and pushes your project files as documented in Lovable's GitHub integration guide.
Once the initial export finishes, click View on GitHub to inspect your files. Commits generated by the platform are authored by the lovable-dev bot and co-attributed to the workspace user who initiated the connection or prompt.
Understanding the exported files and framework architecture
The files and framework structure you receive depend on when your Lovable project was created. Projects created on or after May 13, 2026, use TanStack Start with server-side rendering according to Lovable's TanStack Start documentation. Projects created before that date export as client-side single-page applications using React and Vite as explained in Lovable's external hosting guide.
Your exported repository includes:
- The complete frontend application tree, component files, and styling rules
- Project dependencies and build scripts defined in package.json
- Database schema migration scripts stored in supabase/migrations
The repository intentionally excludes two critical pieces:
- Sensitive values such as API keys and credentials read by edge functions never appear in code according to Lovable's edge function documentation.
- Live database records, customer data, and uploaded storage bucket files
You can export your database, including structure and data, through your project database settings as detailed in Lovable's database backup guide.
Cloning the repository and running locally
Once your code lives on GitHub, you can clone the repository to your local machine for custom development. Copy the repository URL from GitHub or from Lovable's Git settings menu. In your terminal, run git clone with your repository URL, enter the project directory, and execute npm install to install your dependencies.
Before running the local development server, configure your local environment credentials:
- Locate the .env.example file in the root directory.
- Create a local copy named .env in the same directory.
Working locally provides a substantial advantage for project budgets. Editing and saving code yourself does not use credits according to Lovable's code mode guide. Credits are deducted exclusively when the platform's AI agent processes chat prompts in the visual builder. You can run refactoring passes, add helper functions, and test component changes locally without spending workspace credits.
Managing two-way sync and avoiding branch divergence
Lovable synchronizes bidirectionally with GitHub, but it tracks and updates exactly one branch at a time, which defaults to main as described in Lovable's GitHub integration guide. This single-branch architecture creates serious risks if multiple people work concurrently. Pushing commits to main from an IDE while someone actively prompts in Lovable causes branch divergence. When branches diverge, GitHub's commit history overrides Lovable's editor state, which can overwrite visual progress.
To protect your codebase, adopt a structured branching workflow:
- Never push code directly to the active synced branch while edits happen in Lovable.
- Develop custom features on isolated local branches.
- Open pull requests on GitHub so team members can review code changes before merging, matching how GitHub describes pull requests as proposals to review changes collaboratively.
- Protect your default branch against accidental overwrites. As noted in GitHub's protected branches documentation, branch protection rules disable force pushes and prevent branch deletions by default.
You can also read our guide on how to protect main branch on client sites to prevent broken production deployments.
Common sync mistakes and fixes
| Common mistake | Why it happens | Recommended fix |
|---|---|---|
| Attempting to link an existing repository | Lovable requires generating the target repository itself upon connection | Allow Lovable to export to a new private repository, then merge histories locally |
| Missing database rows after deployment | Git sync only copies schema migrations in supabase/migrations | Export database tables manually via database backup settings before external launch |
| Overwriting uncommitted Lovable chat work | Pushing commits to main from an external editor during active AI generation | Build on separate feature branches locally and merge via pull requests |
| Exposing secrets in frontend components | Adding API keys directly into JSX or client components | Move private keys to Lovable Secrets or server-side edge functions |
Giving non-technical clients editing access after export
After exporting the project to GitHub and deploying to hosting, agencies encounter a common handoff dilemma. Clients want to modify landing page copy, update pricing tables, replace team photos, and add testimonials, but they do not know Git and should not be touching raw TypeScript. Inviting clients to edit by submitting prompts inside Lovable can quickly exhaust your account credits or introduce unexpected layout shifts.
We explore several handoff paths in our guide on how to edit a Lovable site without code.
One lightweight option for editing static copy is TurnIntoCMS. It connects to your GitHub repository and gives non-technical clients an on-page visual editor. Clients click text, update links, replace images, or reorder list items directly on a live site preview. Publishing writes each update back to your repository default branch as a single, clean Git commit.
The tool is free for one project and costs $1 USD as a one-time payment for each additional project, with no recurring subscriptions. It works with React, Vite, and Next.js sites where content is stored directly in JSX or imported data files. Note that TurnIntoCMS does not edit live database rows, cannot generate new page layouts, and does not replace full headless CMS platforms when you need dynamic database queries or multi-user editorial approval workflows.
FAQ
Can I export my Lovable project to GitHub on the Free plan?
Yes. Two-way Git synchronization with GitHub, GitLab, and Bitbucket is supported on all Lovable tiers, including the Free plan. Only the offline ZIP file download is locked behind a paid subscription.
Can I connect Lovable to an existing GitHub repository?
No. Lovable must create a brand new private repository during setup and cannot link to a pre-existing repository with prior commits. If you have an existing codebase, let Lovable export to a fresh repository and combine the branches locally using Git.
Do local code edits and GitHub pushes consume Lovable credits?
No. Pushing commits from your local environment to GitHub and syncing them back into Lovable consumes zero credits. Platform credits are only deducted when the AI agent processes natural language prompts inside the chat panel.
Does exporting to GitHub include my live database records?
No. Git sync copies your frontend code, package dependencies, and Supabase schema migration files, but it does not export live database rows. You must export live relational tables separately using the database backup and export tools in your Lovable project settings.
Sources
- Sync your Lovable project with GitHub (docs.lovable.dev, checked November 22, 2026)
- Sync your Lovable project code with GitHub, GitLab, or Bitbucket (docs.lovable.dev, checked November 22, 2026)
- View and edit your project's code (docs.lovable.dev, checked November 22, 2026)
- Upgrade a project to TanStack Start (docs.lovable.dev, checked November 22, 2026)
- Deploying and hosting outside Lovable (docs.lovable.dev, checked November 22, 2026)
- Edge functions (docs.lovable.dev, checked November 22, 2026)
- Back up, restore, and export your project's database (docs.lovable.dev, checked November 22, 2026)
- About protected branches (docs.github.com, checked November 22, 2026)
- Pull requests (docs.github.com, checked November 22, 2026)