Ryan Rueger

Home · About · Teaching · Keys
Mathematics · Computing · Cycling

Passwordless Git over HTTP(s) for Overleaf

 

Believe it or not, you can work with overleaf via Git. Under the project’s menu you can choose Git under the sync options.

This is brilliant if you still prefer the old-school way of writing LaTeX (directly on your computer using $EDITOR as god intended) but are collaborating with people who prefer the Overleaf workflow and ease of use.

However, one minor drawback is that you cannot upload your ssh key for passwordless authentication. This is where git-credential helpers come in.

In your ~/.gitconfig you can define a “helper” for Overleaf. The general block goes as follows

[credential "https://git.overleaf.com"]
  username = <USERNAME>
  helper = "!f() { test \"$1\" = get && echo password=<PASSWORD>; }; f"

The leading ! of the helper command tells git to interpret this as a shell command; which in turn gives us a lot of flexibility. We only need to know that git passes an argument to the helper command which is either get, store or erase. We only need to get the credential value.

Since we may not want our password to be stored in the ~/.gitconfig in plaintext, we can also evaluate a command. For example, if you use pass

  helper = "!f() { test \"$1\" = get && echo password=$(pass overleaf); }; f"

or more crudely, directly with gpg

  helper = "!f() { test \"$1\" = get && echo password=$(gpg -dq ~/.overleaf.gpg); }; f"

Git is documented very well in general, and using password credential helpers is no exception. Looking under man gitcredentials will likely answer any further questions.

Happy Overleafing via git.