Skip to content
Everyday Git

Branches, tags and refs

Create, switch, rename, delete, publish, and read HEAD's reflog with Git's own reason strings.

GitAegis
The GitAegis commit graph, showing branch lanes, merge points, and branch and tag labels against a repository's history.
History mode: the commit graph, with refs where they actually point.

Create, rename, switch

Creating a branch checks that the name is unused and that the start point resolves, then shows the ref movement it will make, from nothing, to the oid the start point names. Renaming runs git branch -m and shows two movements, the old name emptying and the new one filling, with the rollback step spelled out as the inverse command.

Switching is classified caution because your uncommitted work travels with you unless it collides with the target. When it would collide, you can choose the stash-assisted form, and the plan shows all three steps rather than one line labelled “switch”.

planned commands: switch with stash
git stash push -m "WIP on main before switching to fix/session-timeout"
git checkout fix/session-timeout
git stash pop
If the stashed work conflicts with the target branch, the pop stops for resolution. The plan says that before you confirm.

Deleting a branch, and what the plan counts

Deletion is where a branch list can quietly cost you work, so the plan does the reachability arithmetic first. It walks the branch tip against every other ref in the repository and lists, by oid and subject, the commits that would be left with nothing pointing at them.

Branch deletion, classified by what the reachability check found
OperationRiskCaptured first
Delete a fully merged branchsafeNothing: every commit stays reachable elsewhere
Delete a branch holding unmerged commitsdestructiveStandard capsule, untracked files included

The destructive form adds two things: a precondition that you have confirmed force deletion, and a recommended alternative (keep the branch, or merge it first) because the honest comparison is that nothing is lost on that path. Deleting the branch you currently have checked out is refused outright.

Upstreams

Setting a tracking branch checks that the local branch exists, that the remote is configured, and that the remote-tracking ref is actually present. Fetch first if it is not. No network connection is made: this changes local Git configuration only, and the plan says which upstream was there before so the rollback step can name it. Unsetting is the same operation in reverse, and it refuses when there is no upstream to remove.

Tags

A tag is lightweight unless you give it a message, ask for an annotated tag, or ask for a signature. Any of those three makes it annotated, and the plan summary says which kind it is about to create. Creation checks that no tag of that name already exists. Publishing tags is a separate safe push that sends only tags the remote does not already have.

Un-publishing a tag is not automatic

The plan for a tag push states that no rollback is offered: deleting a tag from a remote is its own destructive operation, run deliberately, after you have considered who may already have fetched it.

Every ref, and the reflog

The ref reader returns everything the repository has, refs/heads/, refs/remotes/, refs/tags/, refs/notes/, and GitAegis’s own refs/aegis/ namespace, where recovery refs such as the pre-force-push tip are written. You see what is actually there rather than what a branch list decided to show you.

HEAD’s reflog is read directly from Git, with Git’s own reason strings and ISO timestamps, bounded to at most 1000 entries per read. It includes movements GitAegis never caused (terminal commands, other clients) which is exactly why it is worth reading. An unborn repository returns an empty history rather than an error.

One reflog, not one per ref

This is HEAD’s reflog. There is no per-branch reflog browser in this build. For commits that nothing points at any more, including ones only a branch’s own reflog would name, use Lost Work. It scans wider than a single reflog does.

GitAegis never expires a reflog

No git gc, no git prune, no git reflog expire, not in maintenance, not in cleanup, not anywhere. Two operations in the toolkit carry the word “prune” and neither deletes an object: git remote prune removes remote-tracking refs, and git worktree prune removes registrations for directories that are already gone.

30-day trial · No card required

A recovery capsule before every risky Git operation.

You see the exact commands before they run, and the operation is refused if the capsule cannot be written.

Requires Git 2.38.0 or newer, already installed.

Every risky operation, in this order

  1. Previewthe exact commands, shown before anything runs
  2. Capsulerefs, index, staged and working changes, untracked files, operation state: written to disk first
  3. Executethe commands as shown, or not at all
  4. Journalplan, commands, capsule id, outcome
No capsule, no operation. Restore plans, previews, and takes its own capsule.