Syncing with Overleaf (free)
Nowadays I collaborate with a few (too many) authors on Overleaf for a new paper I’m struggling to finish. To make matters worse, I have a free Overleaf account. An easy addition to my list of headaches. The workaround is to be disciplined in pulling and pushing. You don’t want to have the following problem,
... o ---- o ---- A ---- B origin/master (upstream work)
\
C master (your work)
Here, two separate commits B
and C
were made on remote
and local
branches respectively. The branches have thus ‘diverged’. According to this StackOverflow post, you can either rebase or merge the two branches. This didn’t work for me.
In the end, I had to ditch my local changes in favour of remote changes. This can be done by executing
git reset --hard origin/master
So for next time, I’ll be doing the following:
- Run
git fetch origin
to get all remote changes. Then rungit log origin
. Compare commits withgit log master
(local). - If I observe changes in the previous step, I’ll run
git pull
. - The latest commit must correspond to my supervisor’s. Run
git show HASH:main.tex > main_OLD.tex
whereHASH
refers to the commit hash of a relevant old local commit.HASH
doesn’t have to be the whole string, 5-6 characters will do. - Get
latexdiff
from here. Copy it into the local directory if not already present. Runcp main.tex latexdiff/main.tex && cp main_OLD.tex latexdiff/main_OLD.tex
. - Make sure you have Perl installed. Run
cd latexdiff
and then runlatexdiff -t UNDERLINE main_OLD.tex main.tex > main_DIFF.tex
. - Copy back to local directory by running
cp main_DIFF.tex ../main_DIFF.tex
. - Run
pdftex
on this file and you’re good to go!
Long workaround, but one headache less..