KBAISE/ for lovable
Library
Docs

Sync your Lovable project with GitLab

about 10 minBuildingchecked 40h agoOfficial page
The short version

You can connect your Lovable project to GitLab to automatically save your code there, making it easier to back up, work with others, and use outside Lovable. This connection keeps your project in sync between Lovable and GitLab, allowing changes in either place to update the other.

Anyone who wants to back up their Lovable project code, collaborate with developers, or use their code with other tools needs this feature.

Do this, in order

  1. 1

    As a workspace owner or admin, go to 'Workspace settings', then 'Git', and select 'GitLab'.

    This is where you set up the initial connection between your Lovable workspace and GitLab.

  2. 2

    Click 'Add connection' and choose either 'GitLab.com' for the hosted service or 'GitLab Self-Managed' if your organization runs its own GitLab server.

    You need to tell Lovable which type of GitLab you are connecting to, as the setup steps are slightly different.

  3. 3

    Follow the on-screen instructions to authorize Lovable with your GitLab account. For GitLab Self-Managed, you'll also need to allow Lovable's IP ranges and create an OAuth application in your GitLab instance.

    This step grants Lovable permission to access your GitLab account or instance to create and manage repositories.

  4. 4

    Select the GitLab personal account or group where you want your project repositories to be created and click 'Connect'.

    This links a specific part of your GitLab account (a 'namespace') to your Lovable workspace, allowing projects to be created there.

  5. 5

    Once the workspace connection is active, go to your specific project's settings, then 'Git', and select 'GitLab'.

    Now that your workspace can talk to GitLab, you can link individual projects.

  6. 6

    Under 'Connect project', click 'Connect' next to the GitLab account or group you just linked.

    This creates a new, private GitLab repository for your Lovable project and starts the automatic two-way syncing.

Paste this into your project

I want to connect my Lovable project to GitLab for code backup and collaboration. Please set up a two-way sync for my project with GitLab.com. I will authorize the connection and select the namespace when prompted.

Words decoded

GitLab.com
This is the version of GitLab that is hosted and managed by GitLab Inc. on their own servers, accessible via the internet.
GitLab Self-Managed
This is a version of GitLab that an organization installs and runs on its own computer servers, keeping all the code and data within their own infrastructure.
OAuth
A secure way for you to give Lovable permission to access parts of your GitLab account without sharing your password directly.
API scope
This defines the specific permissions Lovable requests from GitLab, such as the ability to create projects, manage branches, or open merge requests.
Namespace
In GitLab, this refers to a personal account or a group where projects and repositories are organized.
Repository
A digital storage space where all the files, folders, and history of your project's code are kept, often referred to as a 'repo'.
Two-way sync
This means that changes made in Lovable are automatically sent to GitLab, and changes made directly in GitLab are automatically sent back to Lovable, keeping both copies identical.
Branch
A separate version of your project's code where you can make changes without affecting the main version. It's like making a copy to experiment with new features.
Merge request
A way to propose changes made in one 'branch' of code to be combined into another 'branch', typically used for reviewing and approving new features or fixes.
CI/CD pipelines
Automated processes that help developers quickly and reliably build, test, and deploy their software changes.
Allowlist IP ranges
A list of specific internet addresses (IPs) that are permitted to access your system, often used for security to control who can connect to your self-managed GitLab instance.

Where people get stuck

  • Do not rename, move, or delete your GitLab project after connecting it, as this will break the sync and prevent Lovable from updating your project.
  • Do not rename your GitLab username or group that the project lives under, as this will also break the sync.
  • You cannot change the linked GitLab account once connected; you must disconnect and create a new connection as a workaround.
  • If you disconnect and then reconnect a project to GitLab, Lovable will create a *new* repository, not reuse the old one.
  • Lovable only syncs one branch at a time. If you push changes to a different branch in GitLab, they won't appear in Lovable until you merge them into the synced branch or switch Lovable to that branch.
  • If Lovable and GitLab have diverged (both have unique changes), Lovable will push its changes to a 'lovable-sync' branch, and the next sync from GitLab will overwrite Lovable's version of the main branch. Be careful not to lose Lovable-only edits.

The short version, steps, decoder and prompt on this page are written automatically from Lovable's own documentation and can lag or misread it. The official page is always the authority.