Syncing Your GitHub Repo with Overleaf - jamiefogel/Networks GitHub Wiki
Thought for a few seconds
Syncing Your GitHub Repo with Overleaf
This guide shows how to link your GitHub repo Networks with your Overleaf project WhatIsALaborMarket using Git remotes. Once set up, you can seamlessly edit on GitHub, locally, or in Overleaf—and keep everything in sync.
1. Big-Picture Overview
-
GitHub
origin
- URL:
[email protected]:you/Networks.git
- Your canonical source: all
.tex
files, figures, tables, etc.
- URL:
-
Overleaf
overleaf
remote- URL: something like
https://git.overleaf.com/abcdef123456
- Mirrors the same files into your Overleaf project WhatIsALaborMarket.
- URL: something like
-
Local clone
- You work here. Pull/push to both remotes as needed.
2. Prerequisites
- You’ve created a blank Overleaf project named WhatIsALaborMarket.
- You can log in to both GitHub and Overleaf.
- You have Git installed locally.
3. Wiring Up the Remotes
-
Clone (or
cd
into) your existing GitHub repogit clone [email protected]:you/Networks.git cd Networks ```q
-
Add Overleaf as a second remote
- In Overleaf: open 🔧 Menu → Git and copy the “Git clone URL” (e.g.
https://git.overleaf.com/abcdef123456
) - In your terminal:
git remote add overleaf https://git.overleaf.com/abcdef123456
- In Overleaf: open 🔧 Menu → Git and copy the “Git clone URL” (e.g.
-
Verify your remotes
git remote -v # origin [email protected]:you/Networks.git (fetch) # origin [email protected]:you/Networks.git (push) # overleaf https://git.overleaf.com/abcdef123456 (fetch) # overleaf https://git.overleaf.com/abcdef123456 (push)
4. One-Way Sync: GitHub → Overleaf
Whenever you push new commits to GitHub and want to mirror them in Overleaf:
# 1. Make edits locally
git add .
git commit -m "Add new figure and update section 2"
# 2. Push to GitHub
git push origin main
# 3. Push the same branch to Overleaf
git push overleaf main
Overleaf will immediately update WhatIsALaborMarket and recompile the PDF.
5. Two-Way Editing: Overleaf ↔ GitHub
A. Edit in Overleaf → Push to GitHub
- Make edits in the Overleaf web editor.
- Fetch & merge your Overleaf commits locally:
git fetch overleaf git merge overleaf/main
- Push merged changes back to GitHub:
git push origin main
B. Edit Locally or on GitHub → View in Overleaf
- Edit locally or merge a PR on GitHub.
- Push to Overleaf:
git push overleaf main
- Overleaf auto-recompiles with the new content.
6. Handling Merge Conflicts
- If you and someone else edit the same lines in both places, you’ll see a conflict when merging:
git merge overleaf/main
- Resolve conflicts in your local editor, then:
git add . git commit git push origin main git push overleaf main
7. (Optional) Automate with GitHub Actions
To automatically mirror every push to main
on GitHub into Overleaf, add:
# .github/workflows/overleaf-sync.yml
on:
push:
branches: [ main ]
jobs:
push-to-overleaf:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Push to Overleaf
run: |
git remote add overleaf https://git.overleaf.com/abcdef123456
git push overleaf main --force
Now a git push origin main
also updates Overleaf.
8. Summary
- Local work in your
Networks
clone. - Two remotes:
origin
(GitHub) andoverleaf
(Overleaf). - Push to either or both to sync changes.
- Pull/Merge from Overleaf when you edit in the browser.
You get GitHub’s version control and CI plus Overleaf’s collaborative LaTeX environment—without manual uploads or file-count limits.