Connecting Overleaf and Github

I use overleaf for all my academic and collaborative writing. However, I am not a big fan of cloud services. I would always want to have control over my data and not be dependent on external services and access to the internet for my day to day activities. Overleaf provides a good set of features for collaborative writing. And I see no easy way of avoiding it in my workflow.

An alternative way is to leverage the Git feature of overleaf to maintain and work on a local copy of the document. Additionally, this can be used to back-up the data on a Git server such as Github, Gitlab, or self-hosted Git service. The following is the guide I use to create and sync my work between GitHub and overleaf.

Connecting Overleaf and Github

I keep all my repositories private hence do not have to worry about security issues. Avoid using this method for public repositories as it can potentially leak secret URLs(as I have come to believe.)

I start by creating an overleaf project and then using the git URL to clone it onto my system. Then I create an empty repository for this project on my Git server. The following commands in the cloned folder will link the two.

git remote rename origin overleaf
git remote add origin <git url>
git remote set-url origin --add --push
git remote set-url origin --add --push <Git url>

Now, the output of git remote -v should look like this:

origin  <git url> (fetch)
origin<hash> (push)
origin  <git url> (push)
overleaf<hash> (fetch)
overleaf<hash> (push)


Overleaf does not provide ssh URLs; hence, one needs to always enter the username and password, that sucks.

The following lines can be added to ~/.gitconfig to avoid entering the username every time.

[credential ""]
         username = <username>

Important note:

Do not put these repositories in a folder to sync across multiple devices using Dropbox, Nextcloud, etc.

For this, one can use Overleaf’s integration with Dropbox.

comments powered by Disqus