A rebase-based branch sync script hides a dangerous force-push that can destroy teammates' commits.
Codebash
#!/bin/bash
# Sync local feature branch with latest main, then update the remote
git checkout feature
git fetch origin
git rebase origin/main
# Rebase rewrote history, so a normal push is rejected — force it
git push --force origin feature
This rebase-then-push workflow works most of the time but has a subtle, dangerous bug. What is it?