Overleaf and GitHub

Created: 2019-06-19   Category: linux, LaTeX   Print this articleBack to Home


In this post, I describe how I sync LaTeX papers between GitHub and Overleaf.

Suppose you have an Overleaf project https://www.overleaf.com/project/5ce5fb7abb7ad36e4a0f60bf. Overleaf will also provide you a link https://git.overleaf.com/5ce5fb7abb7ad36e4a0f60bf for using with git. Create a Github repository called, say paper, at the address, say git@github.com/[your-github-username]/paper.git.

Clone Overleaf project

git clone https://git.overleaf.com/5ce5fb7abb7ad36e4a0f60bf paper

Overleaf may asks you to input your Overleaf’s username and password. To enable credentials storage in git, use git config --global credential.helper store. For convenience, I want to rename the origin endpoint to overleaf using git remote rename origin overleaf. Then, when pushing and pulling Overleaf’s project, I can simply use git push -u overleaf master and git pull overleaf master.

Pushing to GitHub

git remote add github git@github.com/[your-github-username]/paper.git
git add --all .
git commit -S -m "initial commit"
git push -u github master

Other configuration

I also created a Makefile but do not want to put it in the repository. A simple way is to create .gitignore file and put the name Makefile in that file. An example of a Makefile I created may be as follows.

	git pull overleaf master

	@read -p "Commit message: " MESSAGE; git add --all .; git commit -S -m "$$MESSAGE"; git push -u overleaf master; git push -u github master

	pdflatex main.tex
	bibtex main.aux
	pdflatex main.tex

	rm -rf *.bbl *.pdf *.dvi *.log *.bak *.aux *.blg *.idx *.ps *.eps *.toc *.out *.snm *.nav *.xml *.bcf *.spl *.synctex.gz *~

Valid CSS! Valid HTML 4.01 Transitional Back to Top
Powered by Jekyll
The content on this site is shared under a CC BY-SA 4.0 license, unless otherwise noted