# Work with Git

Canonical HTML: [Work with Git](https://getred.dev/docs/git). Website source: `b212874eefaf200143affa21c770fbb8855a4f5c`. Documented Red release: v0.9.1. Installer source: `b86a2ca4b92e9547d3b174910c82db8a259f5171`.

Review changes, stage hunks or lines, write commits, and use repository operations without leaving Red.

<a id="open-the-git-workspace"></a>

## Open the Git workspace

Press `Space G`. The file list groups staged, unstaged, untracked, and conflicted paths. The detail pane follows the selected file and shows its diff.

Use `Tab` or `Ctrl-w w` to switch panes. Press `?` or `F1` for the actions available in the focused pane.

<a id="review-and-stage-changes"></a>

## Review and stage changes

| Keys          | Action                                                |
| ------------- | ----------------------------------------------------- |
| `[h`, `]h`    | Move between hunks                                    |
| `v`           | Select changed lines                                  |
| `s`, `u`, `x` | Stage, unstage, or discard the selected line or range |
| `S`, `U`, `X` | Stage, unstage, or discard the current hunk           |
| `W`           | Toggle diff wrapping                                  |
| `L`           | Open the complete patch in a scratch buffer           |

Discard operations ask for confirmation. Git authentication uses your existing SSH agent or credential helper.

<a id="create-a-commit"></a>

## Create a commit

Press `Space c c` to open the commit editor. Its first lines show the current branch and staged files. Write the message, then use `:w` or `:wq` to submit it. `:q` cancels.

The commit menu can draft a message from the staged diff when Codex is installed and authenticated. Red places the draft in the editor so you can change it before committing.

<a id="use-repository-operations"></a>

## Use repository operations

The workspace also exposes fetch, pull, push, branches, remotes, tags, stashes, worktrees, logs, reset, and interactive rebase. Open the action list with `?` instead of memorizing every binding.
