This walkthrough covers the commands you'll use every day. It assumes you have installed grit and know roughly what a commit and a branch are. The output shown is what grit prints, minus the colors.
Tutorial
Fifteen minutes with grit. Create a repository, record some changes, work on a branch, and share it with a remote.
Tell grit who you are
Every commit records an author. Set your name and email once, in your global config:
grit reads and writes the same config files as Git, so if you've already set these up for Git, you can skip this step.
$ grit config --global user.name "Ada Lovelace"
$ grit config --global user.email ada@example.comCreate a repository
To work on an existing project instead, copy it with grit clone and skip ahead to the next section:
$ grit init project
Initialized empty repository in /workspace/project/.git
$ cd project$ grit clone https://github.com/gitbutlerapp/grit.gitYour home base: grit status
Running grit with no arguments shows where you are and what's changed. Add a couple of files and look:
The last line always suggests the next step. You'll come back to this screen a lot; grit status (or grit st) shows the same thing.
$ echo "# Notes" > README.md
$ echo "fn main() {}" > main.rs
$ grit
On main — no commits yet
Untracked
? untracked README.md
? untracked main.rs
→ grit add <file> to stageRecord a commit
grit commit stages every change in the working tree and records it in one step:
By default grit commit records every change in one step. When you need tighter control, use grit add (--dry-run, -u, or path lists) and grit commit --staged or grit commit -m "…" -- <paths> to commit only part of the work while leaving other staged edits in the index.
Each grit commit also gets a stable change id that stays with the same logical change when you amend or rewrite history; grit log shows a short change … prefix beside each commit.
$ grit commit "Start the project"
[main 310fdb0] Start the project
2 changes committedgrit log$ grit log
310fdb0 ada just now Start the projectgrit switch -c$ grit switch -c feature
Created and switched to branch feature$ printf 'fn main() {\n println!("hi");\n}\n' > main.rs
$ grit diff
main.rs
@@ -1 +1 @@
1 │ - fn main() {}
1 │ + fn main() {
2 │ + println!("hi");
3 │ + }$ grit commit "Say hi"
[feature 2e409e2] Say hi
1 change committed$ grit show
branch feature
commit 2e409e26f8b370ea1928a8fb93dcf2e025418e1f
Author: Ada Lovelace <ada@example.com>
Date: 2026-10-07 14:55:47 +0000
Say hi
main.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)Merge it back
Switch back to main and merge the branch in. Nothing else has happened on main, so grit just moves main forward:
grit branch -d refuses to delete a branch whose commits haven't been merged into the branch you're on. Use --force-delete (or -D) when you really mean it.
$ grit switch main
Switched to branch main
$ grit merge feature
Fast-forwarded feature → 2e409e2$ grit branch -d feature
Deleted branch feature (was 2e409e2).Share it with a remote
A remote is another copy of the repository, usually on a server. Add one called origin with grit remote add, then push:
grit push sends the current branch to a branch with the same name on origin, creating it if needed. To publish under another name, pass a refspec: grit push origin HEAD:refs/heads/experiment. Set upstream tracking with grit branch -u when you want grit pull to know which remote branch to follow. For GitHub over HTTPS, grit auth signs you in, and grit offers to run it if a push fails for lack of credentials.
To download updates without moving your branch, grit fetch is enough. Fetch a single branch when you do not need every remote-tracking ref:
To get other people's work into your branch, run grit pull. It fetches and integrates: fast-forward when you have no local commits, a merge commit when both sides moved, or a rebase when you pass --rebase (or set pull.rebase):
Use grit pull --ff-only in scripts that must refuse merge commits (exit 128 with refused_not_ff when histories diverged).
If someone pushed before you, a normal grit push is rejected:
To replay your own commits onto another base without fetching first, use grit rebase (default upstream is @{upstream}; --onto for Git's --onto).
After rewriting commits with grit history (reword, drop, fixup, squash, or rebase), fetch so your remote-tracking refs are current, then push with a lease. A plain grit push after a rewrite is rejected with a hint to use --force-with-lease (or pull first):
$ grit remote add origin https://github.com/ada/project.git
Added remote origin → https://github.com/ada/project.git
$ grit push
pushed main → origin refs/heads/main$ grit fetch origin main
refs/remotes/origin/main ← refs/heads/main a8e620a → b52cca6
Fetched 1 update from origin.$ grit pull
Merged origin/main into the current branch (91275a2)
$ grit pull --rebase
Rebased onto origin/main (c4f1a9b)$ grit push
rejected origin refs/heads/main: not a fast-forward — run `grit pull` first$ grit fetch origin
$ grit push --force-with-lease
pushed main → origin refs/heads/mainTag a release
grit tag marks the current commit, and grit push --tags publishes your tags. Signed or tree-sha256 annotated tags can be checked locally with grit tag --verify:
$ grit tag v0.1 -m 'release'
Created tag v0.1
$ grit tag --verify v0.1 --no-signature
tag v0.1 (…): ok
$ grit push --tags
pushed --tags → origin refs/tags/v0.1When things conflict
When grit merge, grit pull, or grit pick hits conflicting changes, grit stops with conflict markers in the worktree and records in-progress state (for pick/revert, Git-compatible CHERRY_PICK_HEAD and .git/sequencer/). Fix the files, grit add the resolved paths, then run grit merge with a normal commit for merges, or grit pick --continue / grit revert --continue for cherry-picks and reverts. Use --abort on the same command to cancel.
grit refuses to switch branches, merge, or pull when your local edits would be overwritten by files that differ on the other side. Unrelated uncommitted edits are kept, like Git. Use grit reset --soft HEAD~1 to uncommit while keeping changes staged.
Offline bundles and linked worktrees
To move commits without a network, grit bundle create writes a single file; grit bundle unbundle ingests it into another repository. For a second checkout of the same repository, grit worktree add creates a linked working tree; grit worktree lock marks one as locked when you need to prevent accidental removal.
Scripting
Every command takes --json and prints a single JSON object, which is handy for scripts and agents. --filter picks out the part you need:
See Scripting with grit for details, and each command's page for its JSON fields.
$ grit status --json --filter '{branch, clean}'
{
"branch": "main",
"clean": true
}Where to go next
Every command has a man page with its options and examples. Start from the command list.