git branch
Creating, Listing, Deleting
The git branch command is essentially a file manager for .git/refs/heads/. Creating a branch writes a new 41-byte file. Deleting one removes it. Listing them reads the directory. Nothing more.
Live Branch Manager
Run commands to create and list branches. Watch the ref files appear and disappear in real time. Click the trash icon or type a branch name and hit delete.
.git/refs/heads/
Terminal
Listing
git branch with no arguments reads every file in .git/refs/heads/ and prints their names. The asterisk (*) marks the branch currently pointed to by HEAD.
Add -v to also print the hash and latest commit message for each branch.
Creating
git branch <name> creates a new file at .git/refs/heads/<name> containing the hash of the current HEADcommit. The new branch points to the same commit you're on right now.
Note: this does not switch to the new branch. For that, use git checkout -b <name> or git switch -c <name>.
Deleting
git branch -d <name> deletes the ref file. Git will refuse if the branch has commits not reachable from any other branch — use -D to force.
Deleting a branch never deletes commits. The commit objects stay in .git/objects/ until git gc cleans up unreachable objects.
Common Patterns
The most common branch operations, including the shorthand that creates and switches in one step.