Code Quiz

Rebase Argument Order Hygiene

A history-cleanup script meant to rebase a feature branch onto main silently rewrites the wrong branch.

Codebash
#!/usr/bin/env bash
set -euo pipefail

# Goal: keep 'feature' linear on top of the latest 'main'
# before opening a pull request.

git checkout main
git pull --ff-only origin main

git checkout feature
git rebase feature main

git push --force-with-lease origin feature

This script is supposed to replay the feature branch's commits on top of the latest main, but it corrupts history. What is the bug?