Squash and Push¶
Utility script that squashes all commits since the merge-base with origin/develop into a single commit and pushes.
Usage¶
What It Does¶
- Fetches all remotes and prunes stale references (
git fetch --all --prune) - Checks that the working tree is clean (no uncommitted changes)
- Finds the merge-base between
HEADandorigin/develop - Counts commits since the merge-base — exits silently if there are none
- Prompts for confirmation (
Proceed? [y/N]) - Prompts for a commit message
- Squashes by soft-resetting to the merge-base (
git reset --soft <merge-base>) - Commits with the provided message
- Pushes to the remote
Interactive Prompts¶
The script requires two interactive inputs:
| Prompt | Input | Default |
|---|---|---|
Proceed? [y/N] |
y or n |
No (abort) |
Message |
Commit message text | Required (cannot be empty) |
Exit Codes¶
| Code | Meaning |
|---|---|
0 |
Push completed successfully, or no commits to squash |
1 |
Error (dirty working tree, no merge-base found, or Git operation failed) |
Prerequisites¶
- Git
- Clean working tree (no uncommitted changes)
- A branch that shares history with
origin/develop