Collaborating on LaTeX documents with Git and Overleaf

LaTeX source is plain text, so co-authoring a paper or thesis works much like working on code. The two usual setups are a Git repository that everyone edits locally, or a shared Overleaf project edited in the browser. Overleaf can also sync with Git, so a team can mix the two.
LaTeX itself has no collaboration or version-control features; all of that comes from the tools around it.
Choosing a setup
Section titled “Choosing a setup”| Git + local editor | Overleaf | |
|---|---|---|
| Setup | Each author installs a TeX distribution and Git | Browser only |
| Editing | Offline, any editor | Online, real-time co-editing |
| History | Full history, branches, tags | 24 hours on the free plan, full history on paid plans |
| Review | Pull requests, git diff, latexdiff | Comments (all plans), track changes (paid plans) |
| Cost | Free | Free plan allows one invited collaborator per project |
Git suits co-authors who already use it and want branches and review. Overleaf suits mixed groups where some authors won’t install anything. Plan limits change, so check Overleaf’s plans page before you rely on them.
Collaborating with Git
Section titled “Collaborating with Git”Repository layout
Section titled “Repository layout”Split long documents into one file per chapter or section and pull them in with \input or \include. Two people editing different files almost never conflict.
% main.tex\documentclass{report}\begin{document}\include{chapters/introduction}\include{chapters/methods}\include{chapters/results}\bibliography{refs}\end{document}Commit only the sources (.tex, .bib, figures, class/style files). Ignore build output so it doesn’t cause pointless conflicts:
*.aux*.bbl*.blg*.fdb_latexmk*.fls*.log*.out*.toc*.synctex.gz*.pdfIf the PDF of a figure is a source file, add it back explicitly (for example !figures/*.pdf).
Write one sentence per line
Section titled “Write one sentence per line”Git diffs and merges work line by line. If each paragraph is one long line, a one-word change shows as the whole paragraph changing, and two authors editing the same paragraph always conflict. Putting each sentence on its own line keeps diffs small, and LaTeX renders the output the same because single line breaks are treated as spaces. When you do have long lines, git diff --word-diff shows the changed words instead of whole lines.
A typical workflow
Section titled “A typical workflow”git clone https://github.com/<you>/<paper>.gitcd <paper>git switch -c methods-rewrite# edit chapters/methods.tex, build locallygit add chapters/methods.texgit commit -m "Rewrite methods section 3.2"git push -u origin methods-rewrite# open a pull request; a co-author reviews and merges itgit switch maingit pullPull before you start each session. Short-lived branches merged often conflict far less than a branch that runs for weeks.
Showing changes to non-Git readers
Section titled “Showing changes to non-Git readers”Supervisors and reviewers usually want a marked-up PDF rather than a diff. latexdiff produces one from two versions of the source:
git show submitted-v1:main.tex > old.texlatexdiff old.tex main.tex > diff.texpdflatex diff.texThis works best on a single file; for documents split with \input, see latexdiff’s --flatten option.
Collaborating with Overleaf
Section titled “Collaborating with Overleaf”- Create a project from a blank document or a template.
- Click Share and invite people by email. Each invited collaborator gets a role: Editor can change content, Reviewer can comment and their edits are recorded as tracked changes, and Viewer can read and download. Link sharing is also available, but the Reviewer role can only be given to named collaborators.
- Everyone edits the same project in real time. Use comments for discussion about specific text and the project chat for everything else.
- Use History to see who changed what and to restore an earlier version, within your plan’s history limit.
Using Git and Overleaf together
Section titled “Using Git and Overleaf together”Git integration and GitHub sync are premium features on Overleaf Cloud, and both work differently from a normal Git remote.
Git integration lets you clone the Overleaf project directly:
git clone https://git.overleaf.com/<project-id>The project ID is the last part of the project’s URL. When prompted, use git as the username and a Git authentication token (generated in Account Settings) as the password; account passwords are no longer accepted. Overleaf’s Git bridge does not support branches or tags, so you push to the single default branch, and the result appears in the Overleaf editor.
GitHub sync links a project to a github.com repository from Integrations > GitHub. It is not automatic: you pull GitHub changes and push Overleaf changes from that menu. If both sides changed, Overleaf pushes its version to a separate, date-stamped branch, and you merge that branch on GitHub or locally. Only github.com is supported; for GitLab or other hosts, use the Git integration instead.
Either way, Overleaf won’t merge branches for you. Branching and conflict resolution happen in Git, outside Overleaf.
Gotchas
Section titled “Gotchas”- Agree on the build. Pin the engine (pdfLaTeX, XeLaTeX, or LuaLaTeX) and the bibliography tool (BibTeX or Biber). A
latexmkrcfile in the repository, or the compiler setting in Overleaf, keeps everyone’s output the same. - Put shared formatting in one place. Keep custom macros and package loading in a single preamble or
.styfile so co-authors don’t each redefine\vecor margins in their own chapter. - Lint the source. ChkTeX flags common LaTeX mistakes, and the nag package warns about obsolete commands and packages. Neither checks spelling or style; run a spell checker separately.
- Large or binary files. Overleaf’s Git bridge doesn’t support Git LFS, and very large pushes can time out. Keep figures reasonably sized, and if a push fails, Overleaf’s docs suggest raising
http.postBuffer.
Further reading
Section titled “Further reading”© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)