Why connect on day one
Three reasons, in order of importance:
- Backup and history. Every change is a commit you can inspect and revert, independent of the platform.
- Ownership. The code is yours in a place you control — no lock-in argument to have later.
- Collaboration. A developer can work in a normal editor while you keep prompting.
It takes two minutes and costs nothing. Do it before the project matters.
How to connect
In the project, open the GitHub option and authorise the integration, then choose the account or organisation and create the repository. Lovable pushes the current code as the initial commit.
For client work, create the repository in the client's organisation from the start — moving it afterwards means re-pointing the connection.
How two-way sync behaves
- Prompt-driven changes in Lovable are committed to the repository automatically.
- Commits you push from your machine or from the GitHub web editor are picked up by Lovable.
- Both sides work from the same default branch.
Two rules keep it painless:
One editor at a time on a file. Finish and push your local edit before prompting Lovable in that same area.
Pull before you push. Lovable commits while you work; pulling first avoids the conflicts.
Working locally
git clone <your-repo-url>
cd <your-repo>
npm install
npm run dev
Edit, commit, push, and Lovable picks it up. This is the standard setup for using an AI code editor alongside Lovable, or for a contractor doing a tricky piece of work.
Branches and pull requests
For anything risky, work on a branch and open a pull request rather than pushing to the default branch. Review the diff, merge when it is right, and Lovable syncs the merged result. This is also how a small team collaborates without stepping on each other.
Common problems
| Symptom | Cause and fix |
|---|---|
| Changes not appearing in Lovable | Pushed to a different branch than the one connected |
| Merge conflict | Both sides edited the same file — resolve locally, push the resolution |
| Repository looks empty | Authorised the wrong account or organisation; reconnect |
| Local build fails but Lovable works | Missing environment variables locally, or dependencies not installed |
What is and is not in the repository
The repository holds your application source. Environment secrets are not committed — they live in the platform's secret storage, which is exactly right. When running locally, supply your own values for anything the app needs.
Reverting a bad change
Two options, both cheap:
- Use Lovable's version history to jump back to a known-good state.
- Use
git reverton the offending commit and push.
Both beat prompting your way out of a broken build, which typically costs more and lands you somewhere new rather than somewhere known.
If you ever leave
The repository is a complete, standard project. You can build and deploy it anywhere that runs a modern JavaScript app. That option existing is the point of connecting early — you rarely use it, but the project is never trapped.
Frequently asked questions
- Does Lovable sync with GitHub both ways?
- Yes. Prompt-driven changes are committed to the repository, and commits you push are picked up by Lovable on the connected branch.
- Why should I connect GitHub early?
- It gives you an independent backup, full change history, code ownership and the ability to bring in a developer at any time.
- How do I avoid merge conflicts?
- Edit in one place at a time, pull before you push, and use branches with pull requests for larger changes.
- Are my secrets stored in the GitHub repository?
- No. Environment secrets stay in the platform's secret storage; the repository holds application source code only.
Go deeper
Related guides
Exporting your Lovable project code
How to get your Lovable source code out, what you own, what comes with it, and what you must recreate if you host the project somewhere else.
Lovable vs Cursor — different jobs, and they work together
Lovable builds and hosts a working web app from plain English. Cursor is an AI code editor for people comfortable in code. Here's how they compare and how to run both on one project.
Lovable Cloud — the backend you don't have to set up
Lovable Cloud gives your app a database, user accounts, file storage and server functions without creating a separate account or wiring keys. Here's what it includes and when you need it.