Git
When the open folder is inside a git repository, the Git panel lists what changed and lets you stage, discard and commit without leaving the editor.
What it needs
ted runs the git installed on your computer, version 2.30 or later; it does not bundle its own. It finds it on the PATH, or you can pick the executable in Settings, Git. Without git, or with a folder that is not a repository, ted works as before and the panel says why it is empty. A folder that is not a repository can be turned into one with Initialize repository.
The Git panel
The Git toggle of the status bar, or Ctrl Shift G, shows the Git panel in place of the explorer; the Files toggle brings the explorer back. The toggle shows how many files changed. The panel lists them in two groups:
- Changes: tracked files that were modified (
M), added (A), deleted (D, struck through), renamed (R) or that have a conflict (!). - Unversioned: files git does not track yet (
U).
Files are grouped by folder; the list button in the header shows them as a flat list with their folder next to the name. Click a group or a folder to fold it, and a file to see its changes.
The changes of a file
Clicking a file in the Git panel opens its changes in a tab, README.md (changes): the whole file against the last commit, in one column, with the line numbers of both versions. Removed lines are red and marked −, added lines are green and marked +, and inside a changed line the words that changed are highlighted. The header sums up the lines added and removed and the number of changes. There is one changes tab: clicking another file shows that one in the same tab, and it follows the file as you edit and save it.
Each change has two buttons on its first line:
- Stage puts only that change in the index, so a commit can take part of a file. A staged change shows Unstage instead.
- Revert puts the lines back as they were in the last commit, in the file and in the index. ted asks first, unless Confirm before discarding changes is off.
Open file opens the file itself in its own tab, to edit it.
History
The History button in the header of the Git panel, or History at the top of the branch menu in the status bar, opens the commit log of the repository in a tab: every branch, remote branch and tag, newest first, with the graph of how they branch and merge. Each commit shows its branches and tags, its subject, its author, how long ago it was made and its short id. The dot of the commit you have checked out is hollow. The log loads in pages as you scroll, so a repository with years of history opens at once.
The search box filters the commits whose message contains the text, ignoring case; a commit id, or its first digits, finds that commit too. While a search is on, the graph is hidden.
Click a commit to see its detail at the right: the whole message, the author and their email, the full id, and the files it changed with the lines added and removed. The log follows new commits, checkouts and pulls by itself.
In the explorer
Inside a repository the explorer shows the same letters next to the changed files, in their colors, and a dot after each folder that holds a change, in the color of the most important one (a conflict, then a deletion, a modification, a rename, an addition, an unversioned file). They follow the status as it changes.
In the editor
A file with changes shows them at the left edge of the line numbers: a green bar on added lines, an accent bar on modified lines, and a short red bar between two lines where lines were removed. The marks compare the file as saved with the last commit, so they hide while the file has unsaved edits and come back, updated, when you save. They only cost a git diff for files the status lists as changed.
Staging
The checkbox of a file, a folder or a group stages or unstages everything under it, as git add and git restore --staged would. It mirrors the git index, so it agrees with the terminal: a file with staged and unstaged changes shows a dash. When files outside the open folder are staged, a notice over the list says so, because they would go into the next commit, and offers to unstage them.
Discarding changes
The undo arrow that appears when you point at a row discards its changes: a modified file goes back to its last committed version, and an unversioned file is deleted. The arrow in the header discards every change. ted asks first, unless Confirm before discarding changes is off in Settings. Discarded changes cannot be recovered.
Committing
The box at the bottom of the panel commits what is staged. Write the message and press Commit, or Ctrl Enter in the message (Cmd Enter on macOS). The line over the buttons says what the commit will include: the number of files and the lines added and removed. The message stays disabled while nothing is staged.
- Amend replaces the last commit instead of adding one. Ticking it with an empty message brings back the last commit's message, so you can also only reword it.
- Commit and push… commits, then lists the commits about to leave and asks before pushing them. The first push of a new branch sets its upstream on the remote.
- The Ctrl+Enter in the message setting makes Ctrl Enter commit and push instead.
ted runs git with your own configuration: your name and email, your hooks, and your credential helper or SSH agent for the remote. While a commit or a push runs, the status bar says so. When one fails, a notification explains why in plain words, and Show git output shows what git printed.
Branches
The status bar shows the current branch (or the short id of the commit, when HEAD is detached), with an up arrow and the number of commits to push and a down arrow and the number to pull. Click it to open the branch menu:
- The search box filters the branches and the actions as you type.
- History (the history tab), New branch, Pull, Push (with the number of commits to push) and Fetch at the top. Pull merges or rebases as your git configuration says (
pull.rebase). - The branches in groups: Recent (the current one and the last ones you checked out), Local and one group per remote. Each one shows its last commit, how long ago it was made, and how far it is ahead or behind its upstream.
- Click a branch, or press Enter on it, to check it out. A remote branch checks out its local branch, creating it when needed.
- The arrow at the end of a branch opens its submenu: check out, a new branch from it, rename and delete. A branch with commits that are not merged anywhere asks again before it is deleted.
- Type a name that does not exist and press Ctrl Enter to create that branch from the current one and check it out.
When you check out another branch with uncommitted changes, ted asks what to do with them:
- Stash and check out keeps them in a stash named after the branch they belong to (
ted-auto:main). When you come back to that branch, ted restores them and says so. - Bring changes takes them to the other branch, which only works when they do not conflict with it.
After a checkout or a pull, the explorer follows the files on disk, and an open file that changed is reloaded, asking first when it has unsaved changes. A rejected push offers Pull and push.
Keeping it current
ted reads the status again by itself, and only when something may have changed, so an idle window does no work:
- right after ted saves a file or runs a git command;
- when git runs outside ted, a
git commit,git addorgit checkoutin a terminal for example: ted watches the repository's.gitfolder; - when the window gets the focus back, for the files other programs changed meanwhile.
The circular arrow in the header reads it at any time. With Fetch automatically on (the default), coming back to the window also fetches from the remote, at most every five minutes, so the status bar shows the commits to pull. A fetch never changes your files, and a failed automatic fetch stays silent. A failed git command shows git's own message in a notification.