Related: LaTeX with GitLab/GitHub and Dropbox PDF sharing
The examples show GitLab but of course work equally well with GitHub/Bitbucket/etc. I use GitLab because of unlimited free private repos.
Do not simply drag and drop your LaTeX directory into Dropbox–you will get syncing errors!
Git is designed to make simultaneous pushes to multiple remote masters. You could backup to several sources at once. Here’s a simple case of using LaTeX with Dropbox as backup to GitHub/GitLab. The same process can be used with OneDrive or Google Drive with their syncing clients installed.
- LaTeX document connected to a GitLab repo, cloned to your computer. Backup your LaTeX document folder somewhere else now as a precaution.
git LaTeX repo ↔ Dropbox
When you do
git push it will go to both simultaneously.
check your current LaTeX repo
cd ~/Dissertation git remote -v
You should see:
origin https://gitlab.com/username/MyDiss (fetch) origin https://gitlab.com/username/MyDiss (push)
Create a directory in your Dropbox folder that is just for your LaTeX Git repos–you can keep multiple LaTeX projects in one Dropbox directory. Let’s call it
Now setup that Dropbox/Git directory as a second push-only remote. You won’t see your files in there because it’s a “bare” Git repo, but the history of all your files are recoverable from it in case your LaTeX git history gets messed up.
cd ~/Dropbox/Git git clone --bare https://gitlab.com/username/MyDiss cd ~/Dissertation git remote set-url origin --push --add ~/Dropbox/Git/Dissertation.git git remote set-url origin --push --add https://gitlab.com/username/MyDiss.git
--pushsays this is just for pushing, not for fetching–we’ll normally fetch (pull) from GitLab since Dropbox is just for rolling backup.
Verify setup by
git remote -v
and you should see:
origin https://gitlab.com/username/MyDiss (fetch) origin https://gitlab.com/username/MyDiss (push) origin /home/computerusername/Dropbox/Git (push)
If you have issues, you can edit
.git/config directly to get rid of errant
%userprofile% is equivalent to
~ on Mac/Linux.
Power users of
might like to access this setup from
Since Windows Command Prompt doesn’t understand
~, you will have to make sure each Terminal you use (WSL, Cygwin) have softlinks created at the same link_name.
Yes, the absolute pathnames are different between WSL and Cygwin, but the softlinks can look the same.
cd ~ ln -s /cygdrive/c/users/joe/Dropbox
Windows Subsystem for Linux
cd ~ ln -s /mnt/c/users/joe/Dropbox
In general I only push/pull from Cygwin or WSL when on a Windows PC because I use SSH on my Git repos with public key authentication.