# Git The Git view is a full-screen page for everything git: it lists every changed file with an inline diff, stages and commits, pulls and pushes, switches branches, and shows each git command it runs in a console. Open it with `Cmd+G`. [Guide index](index.md) · Related: [Git commit form](git-commit-form.md), [Right-click menu](right-click-menu.md#git-rows), [Dialogs](dialogs.md), [Notifications](notifications.md), [Status bar](status-bar.md) ## At a glance ```text +----------------------------------------------------------------------------+ | (1) [ git ] <> main 1 ahead of origin [Pull] [Push ^1] [Close CmdG] | |----------------------------------------------------------------------------| | (2) fix the login form_ | | Jonathan Cmd+Enter commits [Commit 2 files|v] | |----------------------------------------------------------------------------| | (3)|v staged (2) [ ] [Unstage all]| | |> [M] app/Http/UserController.php +4 -1 [Unstage] | | |> [A] app/Models/Invoice.php +31 -0 [Unstage] | | | | (3) v changed (1) [Discard all] [Stage all]| | (4) v [M] README.md +2 -1 [Discard] [Stage] | | (5) 12 | old line || 12 | new line | | 13 | same line || 13 | same line | | ... 40 unchanged lines | | v new . untracked (1) [Delete all] [Stage all]| | v deleted (1) [Restore all] [Stage all]| |----------------------------------------------------------------------------| | (6) [ console ] git (x) | (7) [ branches ] clean . ... | | $ git add -- README.md | local | | $ git commit -m "fix the login form" | |<> main current | | $ git _ | <> feature/a switch -> | | | remote . origin | | | () origin/feature/b checkout->| +----------------------------------------------------------------------------+ ``` 1. **Top bar**: the branch, where it stands against origin, and the Pull, Push and Close buttons. 2. **Commit block**: the message, the author and the Commit button. See [Git commit form](git-commit-form.md). 3. **Section header**: the section name, its row count, and the bulk actions. 4. **File row**: status badge, path, line counts and the row actions. 5. **Inline diff**: the last commit on the left, the working tree on the right. 6. **Console**: every git command the view runs, with its output, and an input line for your own. 7. **Branches**: local branches and the branches on origin. ## Features ### Open and close the view - `Cmd+G`, the **Git** toggle in the [Title bar](title-bar.md), or View > Show Git opens it. The toggle reads `Git N`, where N counts the changed files. - From [Search](search.md) or the [Diff](file-view-diff.md), `Cmd+G` closes it and opens the view. If the view is already open under Search, `Cmd+G` only closes Search. - The view covers the whole window: title bar, columns and status bar. The columns stay as they were under it. Terminals keep running. - When it opens, the keyboard goes to the commit message. - `Cmd+C` with no text selected, outside a terminal, also opens the view on the commit message. - Close it with `Cmd+G`, `Esc`, or the **Close** button. The keyboard goes back to the column that had it. - Dialogs, right-click menus, [Search](search.md), the full-screen [Diff](file-view-diff.md) and [notifications](notifications.md) show on top of the view. `Esc` closes those first, then the view. - While the view is open, the column keys rest (arrows, `Cmd+Left` / `Cmd+Right`). `Cmd+1`, `Cmd+2` and `Cmd+3` still toggle the columns under it. - The view is not remembered: a project always opens with it closed. ### Top bar - `[ git ]`, then the current branch in amber. - Next to it, where the branch stands against its remote: `in sync with origin`, `1 ahead of origin`, `2 behind origin`, `1 ahead · 2 behind origin`, or `no upstream`. - **Pull** shows `↓N` when there are commits to pull. **Push** shows `↑N` when there are commits to push. - Opening the view runs `git fetch origin`, so the ahead and behind numbers are up to date. A repository without an `origin` skips this. ### Sections The changes sit in up to four sections, in this order. A section with no rows is left out. | Section | Colour | What it holds | Row actions | Bulk actions | |---|---|---|---|---| | **staged** | amber | Everything staged for the next commit, whatever its status | Unstage | Unstage all | | **changed** | light amber | Unstaged edits to tracked files; also renames and conflicts | Discard, Stage | Discard all, Stage all | | **new · untracked** | teal | New files git does not track yet | Delete, Stage | Delete all, Stage all | | **deleted** | lilac | Tracked files deleted from disk | Restore, Stage | Restore all, Stage all | - Click a section header to fold or unfold it. - One file can show up twice: once in staged and once in another section. That happens when you staged a file and then edited it again. Each row stands for its own half. - A file with a merge conflict is never staged on its own: it sits in **changed** as a `U` row, and it does not count as a staged file. That row only offers **Stage**. Staging it marks the conflict as resolved. ### File rows Every row, left to right: - A chevron: click anywhere on the row to show or hide its inline diff. - A status badge: `A` new, `M` modified, `D` deleted, `R` renamed, `U` merge conflict (red). Hover it for the word. - The path: the folder dim, the file name bright. A deleted file is struck through. A conflicted file has a red flag after its name; hover it for `Merge conflict — resolve, then Stage`. - The line counts: `+N` in teal and `−N` in light amber. - The row actions, from the table above. Staged rows carry an amber bar on their left edge. A conflicted row carries a red bar and a faint red fill. Red is used for nothing else in the app. ### Row actions - **Stage** and **Unstage** run at once. They never ask. - **Discard** throws away the unstaged changes of a file. The file goes back to its staged version, or to the last commit when nothing is staged. - **Delete** removes a new file from disk. - **Restore** brings a deleted file back. - Discard and Delete ask first by default (`git.confirmDiscard`). See [Dialogs](dialogs.md#discard-changes). Restore never asks. - An open file in the [File view](file-view.md) reloads after a Discard, Delete or Restore. ### Inline diff - The last commit (or the staged version) is on the left, the working tree on the right, lines side by side. - Removed lines have an amber tint, added lines a teal tint. In a changed line pair, the part that differs is highlighted. - Each change keeps 3 unchanged lines around it. Longer unchanged runs fold into `⋯ N unchanged lines`. - A file over 1 MB shows `Too big.`. A file with no text changes shows `— No line changes.`. - For the full-screen comparison, right-click the row and choose **Open diff**, or open the file and use the [Diff](file-view-diff.md). ### Right-click a row Right-click a file row for **Open in editor**, **Open diff**, **Pass on reference** and **Copy reference**. See the [right-click menu](right-click-menu.md#git-rows). Open in editor, Open diff and Pass on reference close the view first. ### Pull and push - **Pull** runs `git pull --no-rebase`. When your branch and origin both have new commits, git merges them. - **Push** runs `git push`, or `Cmd+P` from anywhere. A branch with no upstream yet is pushed again with `git push -u origin `, so the next push needs nothing extra. - While one runs, its button reads `Pulling…` or `Pushing…` and the console header says so. A second Pull or Push is ignored until it ends. - Pull and push stop after 120 seconds. - Helder never asks for a password. Git must already have access to the remote, for example through an SSH key or a credential helper. - A [notification](notifications.md) says how it ended, for example `Pushed 2 commits to origin/main` or `Push failed` with git's error line. ### Console - Every action in the view logs the exact git command, such as `$ git add -- README.md`, and then git's output as it arrives. - Errors read in amber, hints dim, staged and unstaged files from `status` in their colours, and a pushed branch in teal. - Type your own command after `$ git` and press `Enter`. A leading `git` is allowed: `status` and `git status` do the same. - `clear` empties the console. So does the eraser button in its header. - `log` on its own shows the last 30 commits, one line each. - `Up` brings back the commands you typed before, newest first. - Commands run one at a time, in order. Typed commands also stop after 120 seconds. - Git cannot ask you anything here: there is no editor and no pager. A command that needs an editor, such as `commit` without `-m`, stops with git's error. - Click the console log without selecting text to put the cursor on the input line. - The console keeps the last 400 lines. ### Branches - **local** lists your local branches. **remote · origin** lists the branches on origin. - The current branch has an amber bar and reads `current`. A remote branch that has a local branch reads `tracked`. - Click a branch to switch to it (`switch →`). - Click a remote branch with no local branch to check it out (`checkout →`). Git creates a local branch that tracks it. - Switching is locked while there are uncommitted changes. The header then reads `— N uncommitted files · switching locked`, the other branches are dimmed, and a click shows a notification that asks you to commit or discard first. ### When the view is empty - **Not a repository**: `— Not a git repository.` - **Clean working tree**: `— No changes. The working tree is clean.` ### Worktrees A project folder that is a git worktree (or a submodule) works like a normal repository. Helder finds the real git folder and watches it for changes. There is no worktree list or worktree switcher. ### How the list stays up to date You do not need to refresh by hand. The list updates by itself: - **On every change**: Helder watches the project folder and the git folder. Edits by you, by the agent, or by git in a terminal update the list after a short pause. - **On a timer**: as a backstop, git is re-read every 10 seconds by default (`git.refreshInterval`). - **When the view opens**: git is re-read, then origin is fetched. - **After every action**: every git command from the view, typed ones included, re-reads git and the branches when it ends. Pull, a branch switch and typed commands also re-read the file tree and the open file. - **By hand**: `Cmd+R` (View > Refresh) re-reads git, the file tree and the open file. ## Keyboard | Keys | Action | |---|---| | `Cmd+G` | Open or close the Git view; from Search or the Diff, close it and open the view | | `Esc` | Close the Git view (after any dialog, menu, search or Diff on top of it) | | `Cmd+C` | Open the view on the commit message (no text selected, not in a terminal) | | `Cmd+Enter` | Commit, while the view is open (not from the console input) | | `Cmd+P` | Push the current branch | | `Enter` | Run the command in the console input | | `Up` | Recall the previous console command | | `Cmd+R` | Re-read git, the file tree and the open file | ## Settings All settings live in `.helder/config.json`. See [Configuration](configuration.md). | Setting | Default | Effect | |---|---|---| | `git.confirmDiscard` | `true` | Ask before Discard and Delete | | `git.refreshInterval` | `10000` | Milliseconds between automatic git re-reads; `0` turns the timer off | | `git.defaultDiffMode` | `updated` | How a changed file opens; see [File view: Diff](file-view-diff.md) | ## Related - [Git commit form](git-commit-form.md): the message, author and Commit button at the top of the view. - [Right-click menu](right-click-menu.md#git-rows): the menu on a file row. - [Dialogs](dialogs.md): the confirm dialog for Discard and Delete. - [File view: Diff](file-view-diff.md): the full-screen comparison of one file. - [Explorer](explorer.md): shows the same status letters in the file tree. - [Status bar](status-bar.md): branch, line totals and counts while the view is closed. - [Notifications](notifications.md): the messages after a commit, pull, push or branch switch. - [Keyboard shortcuts](keyboard-shortcuts.md): every shortcut in one list.