A browser userscript that adds a "Squash & Recreate PR" button to GitHub pull requests. It creates a new PR with squashed commits while preserving the original description.
- ✨ One-click PR squashing
- 📝 Preserves PR description
- 🔄 Automatically closes original PR
- 🗑️ Deletes original branch
- 🔒 Secure token storage
- ⏳ Progress indicators
- 🏢 Supports GitHub Enterprise
-
Install a userscript manager:
- Chrome: Tampermonkey
- Firefox: Tampermonkey
- Edge: Tampermonkey
-
Install the script from Greasy Fork
- Install Tampermonkey from your browser's extension store
- Click github-pr-squasher.user.js in this repository
- Click the "Raw" button
- Tampermonkey should automatically detect and prompt you to install the script
-
Generate a GitHub token:
- Go to GitHub Settings → Developer Settings → Personal Access Tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Give it a name (e.g., "PR Squasher")
- Select the
repopermission - Copy the generated token (starts with
ghp_)
-
Configure the script:
- Click the Tampermonkey icon in your browser
- Select "Set GitHub Token"
- Paste your token
- For GitHub Enterprise users:
- Select "Set Enterprise Domain"
- Enter your GitHub Enterprise domain (e.g., github.mycompany.com)
- Refresh GitHub
- Navigate to any GitHub pull request
- Look for the "Squash & Recreate PR" button next to the PR title
- Click the button
- The script will:
- Create a new branch
- Create a squashed commit
- Create a new PR with the squashed changes
- Preserve the original PR description
- Close the original PR
- Delete the original branch
- Redirect you to the new PR
To modify the script:
- Clone this repository
- Modify
github-pr-squasher.user.js - Test changes by loading the script in Tampermonkey
- Submit a PR with your changes
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - see LICENSE for details
- Report issues on GitHub Issues
- Submit feature requests through GitHub Issues
- For questions, use GitHub Discussions
- Initial release
- Basic squashing functionality
- Token management
- Progress indicators
- Automatic branch deletion
- GitHub Enterprise support
