Metadata-Version: 2.4
Name: git-prune
Version: 1.0.2
Summary: Clean up your local git branches to match the remote with one command.
Author: Richard
License-Expression: MIT
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.1.8
Dynamic: license-file

# git-prune

Clean up your local git branches to match the remote with one command. This tool synchronizes local git branches with remote branches by removing orphaned local branches that don't exist upstream.

[![PyPI - version](https://img.shields.io/pypi/v/git-prune)](https://pypi.org/project/git-prune/)
[![Python](https://img.shields.io/badge/python-3.8%2B-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)

## Installation

```bash
pip install git-prune
```

## Usage

### Basic Usage

Run from the repository you want to prune:

```bash
git-prune
```

This will:
1. Fetch latest remote references (`git fetch -p`)
2. List local-only branches that don't exist on remote
3. Ask for confirmation before deletion
4. Delete confirmed branches

### Specify Target Directory

Prune a different repository:

```bash
git-prune -d /Path/to/repository
git-prune --directory /Path/to/repository
```

## What Git Prune Does

1. **Fetches** remote references to ensure up-to-date branch list
2. **Compares** local branches against remote branches
3. **Reports** which branches exist locally but not on remote
4. **Deletes** orphaned branches after confirmation

### Example Output

```
Branches ['feature-old-thing', 'temp-experiment'] do not exist in the origin repository. Would you like to delete them? y/N:
```

## Safety Features

- **Fetches first**: Always runs `git fetch -p` before any deletions to ensure you have the latest remote state
- **Requires confirmation**: Never deletes without explicit 'y' approval
- **Protects current branch**: Switches to a safe target branch (main/master or first remote branch) before deleting branches you're currently on

## How It Works

Git Prune uses `git fetch -p` to prune stale remote tracking references, then compares local branch refs against remote branch refs to identify branches that should be removed.

**Before:**
- Local: `main`, `feature-old-thing`, `temp-experiment`
- Remote: `main`, `feature-new-stuff`

**After running git-prune (with confirmation):**
- Local: `main`
- Remote: `main`, `feature-new-stuff`

## License

MIT
