How it works
Draftling has a built-in Git client. Press
Ctrl+W to connect to Wi-Fi, then
Ctrl+G, and Draftling commits your edits,
pulls in anything new from the server, merges the two, and
pushes the result back, using the same standard HTTPS protocol
that desktop git uses. A full commit history is kept
in .git/ on the SD card, so you can also plug the
card into a computer and work with it there.
This works with any standard Git host. Below are step-by-step instructions for the three most common ones. You only need to do this once per device.
No Wi-Fi at hand? You can also sync over a USB cable from a web browser on your computer.
Sync over USB with Draftbridge
Draftbridge
synchronizes your Draftling with a GitHub or Codeberg repository
through a USB cable, from a web browser, without Wi-Fi. You log
in with your GitHub or Codeberg account in the browser, so there
is no access token or git.cfg to set up by hand.
- Connect the Draftling to your computer with a USB cable. Use a desktop version of Chrome, Edge or Opera; Firefox and Safari do not support the Web Serial connection it needs.
- On the Draftling, press F1, select Sync via browser... (letter B) and choose Start. Draftling saves and closes your open documents and waits for the computer.
- On the computer, open bridge.draftling.art, log in with GitHub or Codeberg, choose the repository for your texts (or create a new one), and follow the instructions there to connect to the device and synchronize. The device shows the progress of each transfer.
- When it is done, select Finished on the Draftling (Enter or Esc).
The browser does the same steps as Draftling's own Wi-Fi sync,
on the same Git repository on the SD card, so you can mix the
two freely. Draftbridge points the device's git.cfg
at the repository you chose; to sync over Wi-Fi as well, add an
access token to it as described below.
Needs Draftling 1.0.17 or newer, on a board whose USB port is
the ESP32-S3's built-in USB: the boards that offer "SD card via
USB" in the F1 menu. The Seeed reTerminal E1001 and
Sticky and the Elecrow CrowPanel 5.79" do not support it. The
repository may contain only .md, .txt
and .fountain files. Details:
docs/sync-via-browser.md.
Wi-Fi sync: before you start
-
Create an empty private repository on your
Git host (no README, no
.gitignore, no licence; a completely empty repository is simplest). Note its branch name; new repositories usually default tomain. -
Make sure your Draftling can reach the Internet: use the Wi-Fi
connection dialog in the F1 menu, or put a
wifi.cfgfile on the SD card root with your network name on the first line and the password on the second line.MyHomeWiFi sup3r-secret
Everything below ends with a small text file called
git.cfg on the SD card root. Create it with any text
editor. Keep it private: it contains an access
token.
GitHub
- Open Settings → Developer settings → Personal access tokens → Fine-grained tokens and click Generate new token.
- Give it a name (e.g. draftling) and an expiry date.
- Under Repository access choose Only select repositories and pick your repository.
- Under Permissions → Repository permissions set Contents to Read and write. (This also switches Metadata to read-only automatically, which is fine.)
-
Click Generate token and copy the value. It
starts with
github_pat_and is shown only once.
git.cfg:
repo_url=https://github.com/YOUR-USER/YOUR-REPO branch=main token=github_pat_xxxxxxxxxxxxxxxxxxxx author_name=Jane Doe author_email=jane@example.com
GitLab
- Open your project and go to Settings → Access tokens.
- Click Add new token. Give it a name and an expiry date.
- Set the Role to Developer (or higher).
- Tick the read_repository and write_repository scopes.
-
Click Create project access token and copy the
value. It starts with
glpat-and is shown only once. Note the token's name too; you need it as the username.
git.cfg:
repo_url=https://gitlab.com/YOUR-USER/YOUR-REPO branch=main username=draftling-token-name token=glpat-xxxxxxxxxxxxxxxxxxxx author_name=Jane Doe author_email=jane@example.com
If you use a personal access token (User Settings →
Access Tokens) instead of a project token, set
username to your GitLab account username.
Codeberg
- Open Settings → Applications.
- Under Manage Access Tokens enter a token name (e.g. draftling).
- Expand Select permissions and set repository to Read and Write.
- Click Generate Token and copy the value. It is shown only once.
git.cfg:
repo_url=https://codeberg.org/YOUR-USER/YOUR-REPO branch=main username=YOUR-CODEBERG-USERNAME token=xxxxxxxxxxxxxxxxxxxx author_name=Jane Doe author_email=jane@example.com
The same steps work for any Gitea or Forgejo host, not just Codeberg.
All the git.cfg settings
| Key | Required | Meaning |
|---|---|---|
repo_url | yes | Repository URL. A trailing .git is optional. |
token | yes | The access token you created above (used as the HTTPS password). |
branch | no | Branch to sync. Default main. |
username | no | HTTPS username. Default x-access-token (works for GitHub). GitLab and Codeberg need a real value (see above). |
path | no | Sync into this sub-directory of the repository instead of its root, e.g. notes/. |
author_nameauthor_email | no | Identity stamped on the commits Draftling makes. |
First sync
- Put
git.cfgon the SD card root and insert the card. - Power on Draftling and connect Wi-Fi: press Ctrl+W, or use the F1 menu.
- Press Ctrl+G to sync.
On the very first sync Draftling downloads the repository's history (nothing, for an empty repository), commits your current files, and pushes them up. After that, every Ctrl+G is a quick two-way merge.
If both sides changed the same lines of a file, Draftling writes
both versions into the file with
<<<<<<< /
======= /
>>>>>>> markers and still
commits, so nothing is ever lost. Edit the file to resolve it and
sync again.
Full details of the protocol, the on-card layout and the merge behaviour are in docs/git-sync.md.
Troubleshooting
- Auth failed / 401: wrong token, wrong
username, or the token lacks write access to Contents / repository. - Nothing happens / no Wi-Fi: check the Wi-Fi settings (in
wifi.cfg: network name on line 1, password on line 2, no extra spaces) and that you connected with Ctrl+W first. - 404: check
repo_url; the repository must already exist. - Push rejected: the server's copy changed while syncing. Just press Ctrl+G again.
- Only some files sync: that is by design. Only
.md,.fountainand.txtfiles in the top folder of the card are synchronized; sub-directories, images and other file types are not.