This feature is developed by ayaka-notes/ayakaleaf-pro. It is introduced from v6.4.0 and later. It’s still in beta status. We need your feedback if you have any problem.
Setup GitLab Synchronisation
Create an OAuth application on your GitLab instance, under User settings → Applications (or Admin area → Applications for an instance-wide application):- Redirect URI:
${OVERLEAF_SITE_URL}/user/gitlab-sync/oauth2/callback - Confidential: checked
- Scopes:
api
config/variables.env
Self-managed GitLab
SetGITLAB_SYNC_URL to the web address of your instance, the one you open projects with in the browser. The REST API is derived from it:
Only set
GITLAB_SYNC_API_URL when your instance serves the API somewhere else, for example behind an API gateway.
If your instance uses a certificate from a private CA, mount the CA certificate into the container and point
NODE_EXTRA_CA_CERTS at it, e.g. NODE_EXTRA_CA_CERTS=/var/lib/overleaf/certs/gitlab-ca.pem.Linked accounts and projects belong to the instance they were linked with. Before switching
GITLAB_SYNC_URL to another instance, ask users to unlink their GitLab account and projects.GITLAB_SYNC_PROXY_URL=http://10.0.0.1:10808. It must be a standard HTTP/HTTPS forward proxy, and must not use 127.0.0.1.
Who can link and sync
Like on Overleaf Cloud, only the project owner can link a project to a GitLab repository. Once it is linked, every collaborator with edit access can sync it.- Overleaf talks to GitLab with the GitLab account of the user who syncs, so every collaborator who syncs links their own GitLab account, and needs to be allowed to push to the default branch of the repository.
- View-only collaborators cannot use GitLab Synchronisation for the project.
How syncing works with GitLab
- Permissions: users need to be allowed to push to the default branch of the linked project. When the default branch is protected and the user may not push to it, Overleaf asks them to contact the project owner, as with a repository they lost access to.
- Merging: when a project changed both in Overleaf and in GitLab, Overleaf commits its changes to a temporary branch named
overleaf-YYYY-MM-DD-HHMMSSand merges it through a merge request, because GitLab has no API to merge branches without one. After the merge, Overleaf deletes the temporary branch and the merge request. Only administrators and project owners may delete merge requests in GitLab, so for other users the merged merge request stays in the project. - Merge rules: Overleaf never bypasses the project’s merge rules. When the merge request has a conflict, or needs an approval or a passing pipeline, it stays open and Overleaf asks the user to merge it in GitLab, then to continue syncing.
- Pipelines: commits from Overleaf start pipelines like any other commit. If your project runs pipelines for merge requests and requires them to pass, merges from Overleaf wait for them, as described above.
Q&A
Can I force push to the default branch?
Can I force push to the default branch?
Answer: Please keep force pushes to the default branch disabled. This is GitLab’s default: the default branch of a new project is protected and no one can force push to it. Overleaf can take over a rewritten branch, but GitLab Synchronisation is designed for a default branch whose history only grows.
Can I rename the default branch of a linked project?
Can I rename the default branch of a linked project?
Answer: No. Overleaf keeps syncing with the branch the project was linked to, so syncs fail once that branch is renamed or removed. To sync with another branch, unlink the project, then import the repository into a new project, which uses the current default branch.

