Git empty commits with –allow-empty
Git empty commits with –allow-empty
Use this when you want a commit even if there are no staged file changes:
git commit --allow-empty -m "Your commit message"
How it works
--allow-empty: tells Git to create a commit even when there are no staged changes.- Normally, Git prevents commits with no changes.
- This flag bypasses that restriction.
When empty commits are useful
- Trigger CI/CD pipelines: force a rebuild without code changes.
- Refresh PR/webhooks: force GitHub sync or webhook processing.
- Mark milestones: add a clear history marker (for example,
Release v1.0.0). - Trigger deployment: some CI systems trigger deployments on every commit.
- Test CI configuration: verify pipeline behavior without touching source files.
Example
# Create an empty commit
git commit --allow-empty -m "Trigger CI rebuild"
# Push it
git push origin your-branch
Leave a comment