A user-friendly web tool to generate customizable bash scripts for clearing git repository history while preserving your current files.
- Live Demo
- Features
- How It Works
- Usage
- Tech Stack
- Local Development
- Safety First
- Contributing
- License
Try it out: https://andreagriffiths11.github.io/git-history-cleaner/
- Safe Script Generation - Creates customized bash scripts with proper safety checks
- Backup Options - Automatically includes backup creation commands
- Command Explanations - Learn what each git command does in plain English
- Multiple Output Formats - Copy to clipboard or download as a
.shfile - Input Validation - Sanitizes repository and branch names to prevent common errors
- Customizable - Configure branch names and safety options before generating
Git History Cleaner works entirely in your browser — no data is ever sent to a server.
- You enter your repository name and configure safety options in the UI.
- The tool generates a bash script tailored to your configuration.
- You copy or download the script and run it locally in your terminal.
The generated script uses git's --orphan branch strategy to replace the full commit history with a single fresh "Initial commit" while keeping all your current files intact.
Script flow:
cp -r <repo> <repo>-backup # (optional) create a local backup
cd <repo>
git checkout --orphan <tmp> # create a branch with no history
git add -A # stage all current files
git commit -m "Initial commit"
git branch -D main # delete the old branch
git branch -m main # rename the clean branch to main
git push -f origin main # overwrite the remote history
- Open the tool at https://andreagriffiths11.github.io/git-history-cleaner/.
- Enter your repository name in the "Repository Name" field (letters, numbers, hyphens, and underscores only).
- Configure options:
- Toggle Create Backup to include a local backup step in the script (recommended).
- Set a Temporary Branch Name used during the orphan-branch process (default:
new_branch).
- Click "Generate Script" to produce the customized bash script.
- Copy or download the script using the buttons in the "Generated Script" panel.
- Review the script — expand "Command Explanations" to understand what each step does.
- Run the script in your terminal after verifying it looks correct.
⚠️ Always create a backup and get team approval before running the generated script on a shared repository.
| Technology | Purpose |
|---|---|
| React 19 | UI framework |
| TypeScript | Type safety |
| Vite | Build tool and dev server |
| Tailwind CSS | Utility-first styling |
| Radix UI | Accessible component primitives |
| Phosphor Icons | Icon library |
| Sonner | Toast notifications |
- Node.js 20 or higher
- npm
# Clone the repository
git clone https://github.com/AndreaGriffiths11/git-history-cleaner.git
cd git-history-cleaner
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview the production build locally
npm run preview
# Run the linter
npm run lintThe dev server starts at http://localhost:5173 by default.
This tool generates scripts that permanently delete git history. Always:
- ✅ Create backups before running any generated scripts
- ✅ Review and understand each command before executing
- ✅ Get team approval for shared repositories
- ✅ Test on a copy of your repository first
- ✅ Never run scripts on a production repository without proper testing
Contributions are welcome! Please read CONTRIBUTING.md before submitting a pull request.
This project is licensed under the MIT License — see the LICENSE file for details.
Built with ❤️ by @acolombiadev