Skip to main content
git-filter-repo makes it easy to rename files, directories, and entire directory structures throughout your repository’s history.

Simple Path Renaming

Rename a single file throughout history:

Rename Directories

Move or rename an entire directory:
Include the trailing slash when renaming directories to ensure all files within are renamed correctly.

Multiple Renames

Perform several rename operations at once:

Moving Root to Subdirectory

Make the entire repository root become a subdirectory:
1

Clone the repository

2

Move to subdirectory

All files that were at the root (like README.md) will now be at my-module/README.md.

Combining Extraction and Renaming

Extract a subdirectory and rename it:
This:
  1. Keeps only src/some-folder/some-feature/
  2. Renames it to src/
  3. Removes everything else

Complex Reorganization Example

Restructure a repository layout:
1

Plan the reorganization

Original structure:
Desired structure:
2

Apply multiple renames

Using Paths File for Renames

For many renames, use a paths file with ==> syntax:
1

Create paths file

Create ../renames.txt:
2

Apply renames

Advanced: Callback-Based Renaming

For complex renaming logic, use Python callbacks:

Rename by pattern

Conditional renaming

Replace path components

Renaming with Extraction

Combine path selection with renaming:

Tag Renaming

Rename tags to avoid conflicts when merging:

Complete Example: Repository Merge Preparation

Prepare a repository for merging by reorganizing and prefixing:
1

Clone fresh

2

Extract and reorganize

This:
  • Keeps only the src/ directory
  • Moves everything to modules/extracted/src/
  • Prefixes all tags with extracted-module-
3

Verify changes

Handle Special Cases

Rename preserving directory structure

Case-sensitive rename

On case-insensitive filesystems (macOS, Windows), renaming files that differ only in case requires extra care. git-filter-repo handles this, but be cautious when pushing to remotes.

Verify Renames

After renaming, verify the changes:

Common Patterns

Flatten directory structure

Flattening can cause filename conflicts if multiple files have the same name in different directories.

Add date prefix to directories

Normalize path separators