This is the version of our Overleaf/Git tutorial for people who want to use the CLI instead of TortoiseGit.
Before we get started, you'll need to install Git on your system. On Windows, download it from here and install it. On Linux, just get it from your package manager of choice.
The goal here is to make a local copy of your project, so you can edit the files offline (make a clone, in Git terminology).
In Overleaf, open the project you want to clone, and click Share (in the header bar). Take note of the Git URL listed below Clone With Git (it should look like
git clone <Git URL>. You'll get a prompt asking for your credentials. For the username, fill out your TU/e mail address. For the password, just use your Overleaf password.
By default Overleaf uses some cryptic name for repositories; feel free to move the local copy to a more memorable name, if you want to.
You should now have a local copy of the project.
Now if someone else makes an edit, and you want to have those changes reflected locally, it isn't necessary to clone the project from scratch. Instead you can just download (pull) the changes into your local copy to bring it up-to-date.
Your local copy is now updated with the changes from Overleaf.
First, make some (hopefully useful) changes to your paper. We can't help you with that part ;)
After you made a change, you can commit it.
Select the changes you'd like to commit by running
git add <filename> <filename> .... You can run
git add several times. If you got confused and added stuff that you didn't want added, just use
git reset to start over.
git commit. Git will open a text editor for you to enter a commit message (Git enforces this - but see the Tips section below).
Note that at this point your change hasn't been uploaded to Overleaf yet; you added the change only to your local clone.
To upload (push) your commits so others can see your changes, perform the following steps.
First do a pull, to make sure your local copy is fully updated. (Git will prevent you from pushing commits if your local copy is not up-to-date.) If others indeed pushed any commits in the meantime (even to other files), Git will automatically add a merge commit to merge your work with theirs. If Git cannot merge automatically, it will throw a merge conflict for you to fix manually (see the next section).
Now, to push your commits back to Overleaf, run
The change should be (almost) immediately visible in Overleaf's web interface. Success!
If you pull a commit and Git cannot merge it with your local commits (probably because you both edited the same sentence of a file) you have to merge manually. Git then inserts some conflict markers in your file that look like this:
blah blah <<<<<<< HEAD your version of the sentence ======= the other version of the sentence >>>>>>> (ID of incoming commit) blah blah blah
Open the file in your text editor to remove the conflict markers and retain the version you want to keep.
Commit, as described above. In the commit message, Git will notify you that you are making a merge commit now.
Now you can push like described above.
git commit --allow-empty-message allows you to leave the commit message empty.
Overleaf doesn't support SSH keys, which means that by default you'll have to enter your username and password all the time. To instruct Git to cache your credentials for one hour, run
git config credential.helper "cache --timeout=3600". (For more information and alternatives, see this StackOverflow answer.)