Two small tools that link your git commits to Copilot CLI sessions, and let you resume where you left off.
-
prepare-commit-msg— a global git hook that appends aCopilot-Sessiontrailer to every commit made during an active Copilot CLI session. The format is<session-id>@<host-hash>, where the host hash (sha256 prefix) prevents leaking hostnames into public repos. Auto-detects running sessions (or prompts if there are multiple). -
copilot-git-resume— reads that trailer from the most recent commit and resumes the session, if you're on the same host. Passes through any extra args tocopilot.
# 1. Install the global git hook
mkdir -p ~/bin/git-hooks
cp prepare-commit-msg ~/bin/git-hooks/
chmod +x ~/bin/git-hooks/prepare-commit-msg
git config --global core.hooksPath ~/bin/git-hooks
# 2. Install the resume script
cp copilot-git-resume ~/bin/
chmod +x ~/bin/copilot-git-resume# Work normally — commits get tagged automatically:
git commit -m "Fix the thing"
# → Copilot-Session: 2f291d8a-cff7-48ef-a15b-05e98c9bfbc3@f587e31d
# Later, resume from where you left off:
cd my-project
copilot-git-resume
# With extra args:
copilot-git-resume --yolo --model claude-opus-4.6Fix the thing
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2f291d8a-cff7-48ef-a15b-05e98c9bfbc3@f587e31d
- The hook detects active sessions by checking
~/.copilot/session-state/for recently modifiedevents.jsonlfiles (within 5 minutes). - If
COPILOT_SESSION_IDis set in the environment, it uses that directly. - The host hash is the first 8 chars of
sha256(hostname -s)— enough for matching without revealing the machine name. copilot-git-resumealso handles legacy commits with bare session IDs or the old two-trailer format (Copilot-Session+Copilot-Host).- The hook chains to per-repo hooks if they exist at
.git/hooks/prepare-commit-msg.