Overleaf with GitHub / GitLab

Overleaf paid accounts can edit Overleaf LaTeX documents offline and Git push / pull with Git direct to Overleaf. I don’t use Overleaf with GitHub automatic sync since Overleaf currently requires read/write permission to ALL GitHub repos, public and private. Overleaf should use GitHub Apps instead for granular permissions. Direct Git access does not require special GitHub permissiongs and works with GitLab, GitHub, Bitbucket, etc.

Once the procedure below is done, you’ll be able to:

git push
push local changes (after git commit) to GitLab and Overleaf simultaneously
git push gitlab
push local changes to only GitLab
git push origin
push local changes to only Overleaf
git pull
pull from Overleaf

For simplicity, this procedure assumes the LaTeX project is existing on Overleaf to start. Starting with a project from GitLab is more complicated since Overleaf cannot accept force push.

Connect existing Overleaf to GitLab

Check your current Overleaf LaTeX repo

cd ~/Dissertation
git remote -v

You should see:

origin  https://git.overleaf.com/hash (fetch)
origin  https://git.overleaf.com/hash (push)

Create a new repo Dissertation in GitLab. Do not create any README, LICENSE, or .gitignore. Then connect GitLab as origin:

git remote add gitlab ssh://gitlab.invalid/username/Dissertation

git remote set-url origin --add --push https://git.overleaf.com/hash
git remote set-url origin --add --push ssh://gitlab.invalid/username/Dissertation

Verify Overleaf git remote setup

Verify setup by

git remote -v

and you should see:

gitlab ssh://gitlab.invalid/username/Dissertation (fetch)
gitlab ssh://gitlab.invalid/username/Dissertation (push)
origin  https://git.overleaf.com/<hash> (fetch)
origin  ssh://gitlab.invalid/username/Dissertation (push)
origin  https://git.overleaf.com/<hash> (push)

SECURITY NOTE for GitHub with Overleaf

If you choose to also use GitHub public repos with public Overleaf project, note that merge commits default log message reveals your “secret” Overleaf URL, enabling anyone to edit your public Overleaf project.


  • make Overleaf project private, so that a login/password is required to edit.
  • make GitLab repo private


  • SSH Public Key Authentication is in general recommended for Git
  • You can simultaneously use Overleaf, GitLab, Dropbox, OneDrive, Bitbucket. Just remember to NOT put a LaTeX Git project into a synced Dropbox / OneDrive folder or you’ll get synchronization errors.