# Git

[← Back to README](../README.md)

K3 Studio uses the git CLI (porcelain v2). Status and every git action run on worker threads, so the UI never waits on git.

## Changes and commit

![Changes and diff](images/git.png)

- Changed and staged files with file icons and their side (client / server)
- Side-by-side highlighted diff with a **Stage** button
- Commit, or let **Write** have the agent write the message
- **Amend the last commit** (if the message is empty, the old one is kept)
- An **Undo** bar after commit, stage, unstage, discard (discarded changes are kept in a stash), revert and amend. `Ctrl+Z` works too, as long as the commit is still the tip.

## History

![History](images/git_history.png)

- History with avatars (GitHub by email, initials when offline), refs and age
- A commit view with its files and diffs, **Copy hash** and **Revert**
- Right-click a commit to revert or reset to it
- The Git side panel has a **Changes | History** switch

![Side panel history](images/git_side_history.png)

## Branches and stash

Under the **Branches** tab you can create and switch branches. Under **Stash** you can stash, apply, pop and drop.

## Inline blame

![Inline blame](images/blame.png)

When the caret rests on a line of a saved file that's tracked by git, K3 Studio shows who last changed it, when, and the commit message, at the end of the line.

## Secret guard

![Secrets in this commit](images/git_secrets.png)

Before a commit, K3 Studio checks for secrets: the FiveM license key, the Steam API key, the Tebex secret and the MySQL password. **Move to secrets.cfg** moves those lines into a file that `server.cfg` `exec`s and that is listed in `.gitignore`.

## Focus

With [Focus on a resource](resources.md#focus-on-a-resource), changes (and stage / unstage all) only include that resource.
