git
LaTeX
workflow
version control
document collaboration

git LaTeX workflow

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

A solid Git plus LaTeX workflow makes collaborative writing far less painful, especially for papers, reports, and technical docs with many revisions. The goal is reproducible builds, readable diffs, and clean commit history, not just keeping .tex files under version control. A few structural decisions early save substantial time later during review and publication deadlines.

Organize Repository for Predictable Builds

Keep source files and generated artifacts clearly separated.

Recommended structure:

  • src/ for .tex, bibliography, and figures.
  • build/ for generated files.
  • root level scripts for build commands.

Initialize with simple baseline:

bash
mkdir paper && cd paper
git init
mkdir -p src build

Main LaTeX file example in src/main.tex:

tex
1\documentclass{article}
2\begin{document}
3Hello LaTeX with Git.
4\end{document}

Ignore Generated Files Aggressively

LaTeX produces many temporary files that should not be committed.

gitignore
1*.aux
2*.bbl
3*.bcf
4*.blg
5*.fdb_latexmk
6*.fls
7*.log
8*.out
9*.synctex.gz
10build/

Committing artifacts creates noisy diffs and merge conflicts that add no authoring value.

Use latexmk for Repeatable Compilation

latexmk automates multi pass compilation and bibliography reruns.

bash
latexmk -pdf -interaction=nonstopmode -output-directory=build src/main.tex

This single command is easier for teams than manual pdflatex and bibtex sequences.

You can add a simple build script:

bash
#!/usr/bin/env bash
set -euo pipefail
latexmk -pdf -interaction=nonstopmode -output-directory=build src/main.tex

Version this script so all contributors build the same way.

Make Diffs More Reviewable

LaTeX source diffs can still be noisy. Keep writing modular:

  • one sentence or logical unit per line.
  • split large sections into included files.
  • keep macros centralized.

Include files pattern:

tex
1% src/main.tex
2\input{sections/introduction}
3\input{sections/method}
4\input{sections/results}

This improves merge behavior and keeps pull requests focused.

Teams also benefit from agreeing on a macro policy. If every author invents local shorthand commands for formatting, diffs become harder to read and papers become harder to maintain close to submission time.

Branching and Commit Strategy

For writing workflows, small focused commits work better than giant chapter dumps.

Good commit examples:

  • intro: clarify problem statement
  • methods: add experiment setup subsection
  • refs: update conference citation

Use feature branches for larger edits and open pull requests for review comments.

Handle Figures and Binary Assets

Binary files like images and PDFs do not merge well. Keep source figure files when possible and avoid repeatedly rewriting large binaries in small commits.

If project includes many large assets, consider Git LFS for selected file types.

bash
git lfs track "*.png"
git lfs track "*.pdf"

Only adopt LFS if team infrastructure supports it.

Add CI for Build Verification

A lightweight CI check that compiles LaTeX catches missing packages and broken references early.

Example CI command:

bash
latexmk -pdf -interaction=nonstopmode -halt-on-error -output-directory=build src/main.tex

Failing early in pull requests is better than discovering broken builds right before submission.

Collaboration Tips for References

Bibliography files are frequent conflict points. Keep citation edits small and sorted. If using one shared .bib, ask contributors to run consistent formatting tools before commit.

For larger teams, one person can periodically normalize bibliography formatting to reduce ongoing merge noise.

If citation files are especially active, consider a quick validation step in CI with bibtex or biber through the normal build command. Catching malformed entries early is much cheaper than debugging them right before submission.

Review Friendly Change Comparisons

For major text edits, regular source diff is useful, but reviewers may also want semantic document changes. Tools such as latexdiff can generate visual comparison PDFs between revisions.

bash
latexdiff old.tex new.tex > diff.tex
latexmk -pdf -output-directory=build diff.tex

Use this selectively for large revisions so reviewers can focus on content changes, not only line based source differences.

Common Pitfalls

  • Committing generated .aux and .log files and creating unnecessary conflicts.
  • Building with inconsistent local commands across contributors.
  • Keeping giant monolithic .tex files that are hard to review and merge.
  • Letting figure binaries dominate commit history without strategy.
  • Waiting until final deadline to run reproducible clean build checks.

Summary

  • Structure repository to separate source from generated artifacts.
  • Use .gitignore and latexmk for clean, reproducible builds.
  • Keep LaTeX sources modular and diff friendly for collaboration.
  • Use focused branches and commits to improve review quality.
  • Add build verification in CI to catch errors early.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.