Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

git-branch-refresh

A Claude Code SessionStart hook that keeps the status-line branch label in sync with your actual git branch.

Problem

When you switch git branches and resume a conversation with --resume, the Claude Code UI continues showing the branch from the original session start. (#37429)

How it works

The hook runs git branch --show-current at every session start and emits a status-line update so the displayed branch always matches reality. It handles detached HEAD states gracefully by showing the short commit SHA.

Install

# Clone and install
git clone <repo-url> && cd git-branch-refresh
bash install.sh

This adds a SessionStart hook to ~/.claude/settings.json. No other configuration is needed.

Requirements

  • jq — used by the installer to safely merge into your settings file
  • Git 2.22+ — for git branch --show-current (older versions fall back to rev-parse)

Manual install

If you prefer, add the hook to ~/.claude/settings.json yourself:

{
  "hooks": {
    "SessionStart": [
      {
        "type": "command",
        "command": "/absolute/path/to/git-branch-refresh.sh"
      }
    ]
  }
}

Uninstall

Remove the git-branch-refresh.sh entry from the SessionStart array in ~/.claude/settings.json.

Testing

make test    # syntax check (bash -n)
make lint    # shellcheck