HookMITv1.0.0awesome-copilotruns code
Session Auto-Commit
Automatically commits and pushes changes when a Copilot coding agent session ends
At a glance
- Kind
- Hook · Ananke
tool - Reference
awesome-copilot/session-auto-commit·ananke://tool/awesome-copilot/session-auto-commit@1.0.0- Files
- 3 · 3.7 KB
- How it's used
- Hooks run their command automatically when the listed session events fire. Review the script before enabling it.
Upstream metadata
tags | automation, git, productivity |
|---|
Hook events
| Event | Command | Timeout |
|---|---|---|
sessionEnd | .github/hooks/session-auto-commit/auto-commit.sh | 30s |
Documentation
View upstream ↗Automatically commits and pushes changes when a GitHub Copilot coding agent session ends, ensuring your work is always saved and backed up.
Overview
This hook runs at the end of each Copilot coding agent session and automatically:
- Detects if there are uncommitted changes
- Stages all changes
- Creates a timestamped commit
- Pushes to the remote repository
Features
- Automatic Backup: Never lose work from a Copilot session
- Timestamped Commits: Each auto-commit includes the session end time
- Safe Execution: Only commits when there are actual changes
- Error Handling: Gracefully handles push failures
Installation
-
Copy this hook folder to your repository’s
.github/hooks/directory:cp -r hooks/session-auto-commit .github/hooks/ -
Ensure the script is executable:
chmod +x .github/hooks/session-auto-commit/auto-commit.sh -
Commit the hook configuration to your repository’s default branch
Configuration
The hook is configured in hooks.json to run on the sessionEnd event:
{
"version": 1,
"hooks": {
"sessionEnd": [
{
"type": "command",
"bash": ".github/hooks/session-auto-commit/auto-commit.sh",
"timeoutSec": 30
}
]
}
}
How It Works
- When a Copilot coding agent session ends, the hook executes
- Checks if inside a Git repository
- Detects uncommitted changes using
git status - Stages all changes with
git add -A - Creates a commit with format:
auto-commit: YYYY-MM-DD HH:MM:SS - Attempts to push to remote
- Reports success or failure
Customization
You can customize the hook by modifying auto-commit.sh:
- Commit Message Format: Change the timestamp format or message prefix
- Selective Staging: Use specific git add patterns instead of
-A - Branch Selection: Push to specific branches only
- Notifications: Add desktop notifications or Slack messages
Disabling
To temporarily disable auto-commits:
- Remove or comment out the
sessionEndhook inhooks.json - Or set an environment variable:
export SKIP_AUTO_COMMIT=true
Notes
- The hook uses
--no-verifyto avoid triggering pre-commit hooks - Failed pushes won’t block session termination
- Requires appropriate git credentials configured
- Works with both Copilot coding agent and GitHub Copilot CLI