Sync your Lovable project with GitHub
You can connect your Lovable project to GitHub to automatically save your code there and work with others. This lets you keep a copy of your project outside Lovable, collaborate with developers, and use GitHub's tools.
Anyone who wants to back up their Lovable project code, collaborate with developers, or use GitHub's features like version control and deployment.
Do this, in order
- 1
Go to your Lovable workspace settings, find the 'Git' section, and then choose 'GitHub'.
This is where you'll set up the main connection between Lovable and your GitHub account or organization.
- 2
Click 'Add connection' and follow the on-screen instructions to link your GitHub account or organization to Lovable.
This step gives Lovable permission to create and manage code repositories on your behalf in GitHub. You'll choose the type of GitHub you use (like the standard github.com).
- 3
Once the workspace connection is active, go to your specific project's settings, find the 'Git' section, and then 'GitHub'.
Now that Lovable can talk to GitHub, you need to tell it which project should be linked to a new GitHub repository.
- 4
Click 'Connect' next to the GitHub account you just linked.
Lovable will automatically create a new, private GitHub repository for your project and start keeping it in sync. Any changes you make in Lovable will appear in GitHub, and vice-versa.
- 5
To work on a specific part of your project, use the 'branch picker' in your project's GitHub settings to switch to an existing branch or create a new one.
This allows you to manage different versions of your code, work on new features without affecting the main project, and collaborate effectively.
Paste this into your project
I want to connect my Lovable project to GitHub. Please set up a two-way sync so my project code is backed up and I can collaborate with others. I'm using the standard github.com. Once connected, please create a new branch called 'feature-alpha' from the main branch and switch my project to sync with it.
Words decoded
- Repository
- A digital folder where all the files, history, and changes for a specific project are stored on GitHub.
- Two-way sync
- When changes made in Lovable are automatically sent to GitHub, and changes made in GitHub are automatically brought back into Lovable, keeping both copies identical.
- Branch
- A separate version of your project's code. You can make changes on a branch without affecting the main version, and then combine them later.
- Workspace connection
- A general link between your entire Lovable workspace (where all your projects live) and a GitHub account or organization, allowing Lovable to interact with GitHub.
- Project repository link
- A specific link between one of your Lovable projects and one particular GitHub repository, enabling the two-way sync for that project.
Where people get stuck
- Do not delete your GitHub repository after linking it, as this will stop the sync.
- If you disconnect a project and then reconnect it, Lovable will create a *new* GitHub repository, not link back to the original one.
- Lovable cannot import existing GitHub repositories; it only exports your Lovable project to a new GitHub repository.
- If Lovable and GitHub 'diverge' (have different changes), Lovable will create a special 'lovable-sync' branch instead of updating your main branch, and the next sync from GitHub will overwrite Lovable's version of the branch.
- When creating a new branch, ensure you are on the correct 'source' branch first, as the new branch will be created from the currently active branch, not necessarily the main one.
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.