I'd like to push changes of an overleaf project to multiple branches besides the master on Git. Would that be possible?
4 Answers
If by "overleaf" you mean that Git repository project has multiple sub-project as submodules, then said overleaf project can:
- loop over its submodules
- push its
master
to any branch it wants for each submodule subrepo.
But if it is the opposite, meaning a subproject derived from the overleaf project knows about said overleaf project (and the overleaf one has no idea of how many subprojects there are), then you need a script which, in each subproject repo, would fetch the main project master
branch -- for instance -- to any local branch you need.
git fetch mainProject master:myBranch

- 1,262,500
- 529
- 4,410
- 5,250
It looks like the Overleaf web UI only cares about the main branch:
Known Limitations
Branches: The Overleaf Git system does not support branching.
Source: https://www.overleaf.com/learn/how-to/Using_Git_and_GitHub

- 6,125
- 3
- 30
- 27
I am not sure if I understand your need, but I would like to share my solution.
Suppose I have a Git repo, which contains folders src
(source code), note
(tex files), res
, etc for a project. All folders are synced to GitHub. But I want to only sync the note
folder to the overleaf.
Without creating another repo for overleaf, I create a branch named paper
, and sync it with overleaf.
Step 1: create paper
branch
git checkout --orphan paper
where --orphan
creates a new branch, but it starts without any commit.
In the paper
branch, remove other folders and only keep the note
folder.
Step 2: add overleaf as another remote repo
Follow the official instruction from overleaf to obtain the git link at overleaf, then add it as a remote repo
git remote add overleaf https://git.overleaf.com/XXXXXXXXXXX
Step 3: git pull & push
Note that the default branch on overleaf is master
, but our local repo branch is paper
. We can set the upstream for tracking the changes,
$ git branch --set-upstream-to=overleaf/master paper
Branch 'paper' set up to track remote branch 'master' from 'overleaf'
$ git pull
To push local changes, we need to specify the local and remote branch names paper:master
.
$ git push overleaf paper:master

- 77
- 5
I have linked Overleaf with Dropbox. Now I can use git traditionally via the local Dropbox integration. If you change the branch you have to wait for Dropbox to sync, then you will also see the changes in Overleave.

- 1