# Requirement Specification / 需求规格说明
# git-bak-remotes

## Background / 背景

When working with remote Git repositories, developers often need to create local snapshots of all remote branches before performing destructive operations (force-push, branch cleanup, rebasing, etc.). A batch backup command ensures that all remote branch states are preserved locally with a date-stamped naming convention for easy identification and cleanup.

## Goals / 目标

- [x] Batch backup all remote branches to local branches
- [x] Use naming convention: `bak-{date}/{original_branch}`
- [x] Auto-detect today's date, support custom date string
- [x] Local only — no push
- [x] Support --force to overwrite existing backups

## Scope / 范围

### In Scope / 范围内
- Fetch latest remote state before backup
- Create local branches from remote tracking branches
- Date-stamped backup prefix (bak-YYYY-MM-DD)
- Skip existing backup branches (unless --force)
- Configurable remote name (default: origin)

### Out of Scope / 范围外
- Pushing backup branches to remote
- Restoring from backup branches
- Pruning old backup branches automatically

## Acceptance Criteria (EARS format)

- [x] When user runs `l git bak-remotes`, the system shall fetch from origin and create local `bak-{today}/{branch}` for every remote branch
- [x] When a backup branch already exists, the system shall skip it with a message
- [x] When `--force` is specified, the system shall overwrite existing backup branches
- [x] Where `--remote` is specified, the system shall use that remote instead of origin
- [x] Where `--date` is specified, the system shall use that date string in the prefix

## Constraints / 约束条件

- Requires Git installed
- Must be inside a Git repository
- HEAD -> tracking branches are excluded (e.g., `origin/HEAD -> origin/main`)

## Implementation / 实现

- **File**: `src/commands/git/bak_remotes.rs`
- **Command**: `l git bak-remotes [-r REMOTE] [-d DATE] [-f]`
- **Status**: ✅ Completed

## Open Questions / 待澄清问题

- (None)
