Syncing your project to a git remote

TeXType already keeps a project's history as commits in its own git repository. Sync copies that history to a repository you control (on GitHub or GitLab, for example) shortly after you save. That gives you a backup outside TeXType that you can clone, read and keep.

Sync is part of Pro, and only a project's owners can set it up. Cloning straight from TeXType (below) works on every plan, and pushing to it (below) on Pro.

Pushing is automatic; pulling is not. Your saves are pushed to your repository. Commits made directly on GitHub do not arrive by themselves: press Pull in the sync dialog to bring them in. If the repository is only ahead of the project, its commits apply cleanly. If both have changed, you can choose Merge histories (conflicts appear as markers in the text, which you resolve in the editor) or Use the remote's history in place of the project's. Using the remote's history is also how you start a new project from an existing repository.

Pulled commits keep their authors, and History marks each one pulled from GitHub by (or GitLab) the owner who linked the repository. Anyone who can write to that repository can write any name in a commit, so an author is shown as a member of the project only when the address is that owner's own; any other name and address is shown as written in the commit.

1 · Create a repository to sync into

  1. On GitHub: New repository, private, any name.
  2. Create it empty: do not tick "Add a README". An empty repository accepts the first push cleanly. Sync does not create repositories itself.

If you sync into a repository that already has history, do not use its existing branch: in step 3, set the branch to an unused name such as textype. The Check target button in the sync dialog tells you whether your choice is safe before anything is pushed.

2 · Create a fine-grained personal access token

A fine-grained token can be limited to exactly one repository with exactly one permission, so a leak of this credential exposes only this backup — not your account.

  1. On GitHub, open Settings → Developer settings → Personal access tokens → Fine-grained tokens → Generate new token.
  2. Resource owner: you (or the organization that owns the repository).
  3. Expiration: your choice; a year is reasonable. You do not need to note the date: the project's sync indicator turns amber two weeks before the token expires (the dialog shows the day), and pasting a new token fixes it.
  4. Repository access: Only select repositories → pick the repository from step 1.
  5. Permissions → Repository permissions → Contents: Read and write. (Metadata: read-only is added automatically.) Nothing else is needed.
  6. Generate the token and copy it: GitHub shows it only once.
Organization-owned repository? The organization must allow fine-grained tokens (some require an approval step after you create one). If yours doesn't, a classic token with the repo scope works everywhere but grants access to every repository you can reach — scope it mentally as "my whole account" and store it nowhere else. For SAML/SSO organizations, remember to click Authorize for the org after creating a classic token.

3 · Connect it in the sync dialog

  1. Paste the token into Access token and click Save token and browse. Pick your repository from the list, and the URL and branch are filled in. (Or paste the repository's https://… URL by hand.)
  2. Leave Username blank: GitHub ignores it when you use a personal access token. (GitLab wants your username there; see GitLab below.)
  3. Branch: main for an empty repository; an unused name like textype otherwise.
  4. Click Check target and read what it says.
  5. Leave Push automatically after every save on (it is the default), then click Save, then Push now.
  6. Refresh the repository on GitHub: your project's full history is there.

From then on, edits are pushed automatically: about ten seconds after a save, one push carries everything since the last one. The dialog's status line shows the last pushed commit, and any failure with its reason. Most failures are retried automatically; a rejected token or a missing repository waits until you change the sync settings.

Where the token lives

The token is encrypted on the server the moment it is saved and is never sent back to any browser — the dialog can only replace it, not reveal it. Even so, scope tokens minimally: one repository, contents-only, with an expiry.

When it breaks later

Fixing a branch that was pushed to by accident

Pushes stop with "the remote has commits this project does not" when something reached the synced branch from outside the editor, such as an edit made directly on GitHub or a push from a clone. The Pull button in the sync dialog resolves this (by merging, or by using the remote's history). If you would rather fix it by hand, there are two ways, the safer first.

Option 1: sync to a new branch. This leaves the old branch as it is:

  1. In the sync dialog, change Branch to an unused name (such as backup-2).
  2. Save, then Push now. The project's full history lands on the new branch.
  3. The old branch stays on GitHub as it was. If the stray commits contain anything worth keeping, read them there and paste what you need into the editor.

Option 2: keep the branch name by resetting it. This removes the stray commits from GitHub, so first save what you need from them:

  1. If anything in the stray commits matters, bring it in through the editor: view the commit on GitHub and paste the changes into the project. The editor's copy is the one that counts.
  2. On GitHub, delete the synced branch: repository → Branches → 🗑. If GitHub refuses because it is the repository's default branch, first switch the default to any other branch (Settings → General → Default branch; if there is no other branch, create one on GitHub first), then delete the synced branch.
  3. Back in the editor, click Push now. The branch is recreated with the project's full history, and automatic pushes resume.
Prevention: on GitHub, add a branch protection rule to the synced branch that lets only you push to it (the sync token acts as you). Collaborators with access to the repository then cannot push to it by accident.

GitLab

The same three steps, with GitLab's names for things. This works for gitlab.com and for a self-hosted GitLab whose address contains "gitlab" (such as gitlab.example.edu), since the sync dialog recognizes GitLab from the URL. For a GitLab at another address, paste the clone URL and use Check target; browsing is not available there.

  1. Create an empty project on GitLab: New project → Create blank project, private, and untick Initialize repository with a README.
  2. Create a personal access token: your avatar → Preferences → Access tokens → Add new token. Scopes: read_repository and write_repository. Nothing else is needed. Set an expiry; the sync indicator warns two weeks before it lapses.
  3. In the sync dialog: first paste the new project's HTTPS clone URL (on GitLab, Code → Clone with HTTPS) into Remote URL. A blank Remote URL means GitHub, so the dialog would send your GitLab token there. Username is your GitLab username (the one in your profile URL, not your email), and the token goes in Access token. Then Save; Save token and browse lists your GitLab projects if you want to pick another.
Project access tokens (created inside one project's settings rather than your account's) work too, with the same two scopes; then the username is the token's name, and browsing lists only that one project, since it is all the token can see. If browsing shows no projects or reports the token rejected, this is the first thing to check.
A push that fails with "HTTP 502" even though the target check succeeded is gitlab.com refusing a push sent in chunks. The editor sends pushes whole to avoid it, and retries automatically. If it keeps failing, the problem is at gitlab.com, not in your configuration.

Cloning straight from TeXType

You do not need GitHub to have the project on your own machine. TeXType is itself a git remote, on every plan:

  1. On your account page, under Access tokens, make a token for the project. Copy it; it is shown once.
  2. Copy the clone command shown when you make the token (if you own the project, it is also under Clone with git in its Sync dialog), and run it:
    git clone https://textype.io/git/<project-id>
  3. When git asks, give any username and the token as the password. If your system has a credential helper, it remembers the token, so a later git pull does not ask again.

The clone has the files and their whole history, including what was typed a moment ago: the project saves before git reads it. Comments and suggestions are not files and are not in the clone; they stay in TeXType.

A token stops working when it expires, when you revoke it, when you sign out of every device, or when you leave the project.

Pushing to TeXType

On Pro, git push changes the project itself, and everyone who has it open sees the change as it arrives. It needs a token made to Read and push (a read token is refused), and an editor's or owner's place in the project; the plan is the project owner's.

Other hosts

Browsing repositories works for GitHub and GitLab, but sync itself works with any host that accepts an authenticated https:// push:

Connect your AI tools to TeXType: connecting Claude, ChatGPT, Claude Code or Codex to your projects, and reviewing what they suggest. AI tools never push to git themselves. Where a project allows new files, a file an AI tool adds is a version like any other, so a synced project pushes it to your repository.