A comprehensive collection of 50+ Git utility scripts solving real workflow problems
# Clone the repository
git clone https://github.com/jim-my/git-scripts.git
cd git-scripts
# Install all scripts
./install.sh
# Start using immediately
git check-dup # Find duplicate commits
git experiment start my-feature # Safe experimentation
git wtf # Enhanced status| Script | Purpose | Why Use It |
|---|---|---|
| git-check-dup | Find duplicate commits between branches | Detects identical content with different hashes |
| git-experiment | Safe code experimentation sandbox | Isolated development with automatic cleanup |
| git-search-in-each-commit | Search through commit history | Fills gap in git's "contains pattern" search |
| git-when-reached-branch | Determine when commit reached branch | Comprehensive merge detection with confidence levels |
| git-dedupe | Clean branch history automatically | Remove duplicates and rebase cleanly |
| git-split-amended-commit | Split accidentally merged commits | Fixes accidental git commit --amend mistakes |
| git-wtf | Enhanced repository status | Branch relationships and sync status |
- git-check-dup - Find commits with identical content between branches
- git-dedupe - Remove duplicate commits and rebase cleanly
- git-remove-from-history - Completely remove files/directories from history
- git-search-in-each-commit - Search for patterns across commit history
- git-when-reached-branch - Track when commits reached specific branches
- git-branch-current - Get current branch name safely
- git-branch-diff - Visual diff of commit logs between branches
- git-branch-new_and_track - Create and track new branches
- git-branch-not-merged - List unmerged branches
- git-branch-set_tracking - Configure branch tracking
- git-branch-show - Show branch information
- git-branch-tracking - Display tracking relationships
- git-delete-local-merged - Delete local branches merged into current
- git-promote - Promote local branch to remote tracking
- git-amend - Amend last commit with staged changes
- git-experiment - Safe experimentation with isolated branches
- git-stage-all - Stage all changes with confirmation
- git-stash-smart - Enhanced stash management with search
- git-undo - Undo last commit but keep changes staged
- git-up - Enhanced pull with change summary
- git-reup - Pull with rebase and change summary
- git-diff_with_prev - Compare with previous version
- git-resolve-conflict - Guided merge-conflict resolution with auto re-merge and review
- git-untracked-conflict - Classify untracked files that would block a merge/pull
- git-diff-branch - Compare branches with enhanced output
- git-diff-changed_files - Show only changed file names
- git-diff-theirs_combined - Show their changes in merge conflicts
- git-diff-with-2nd-parent.rb - Compare with second parent in merges
- git-icdiff - Side-by-side diffs with icdiff
- git-show2 - Enhanced git show with better visualization
- git-show-vim - Show commits in vim
- git-incoming - Show incoming changes from remote
- git-log-merges - Enhanced merge commit log
- git-log-search_all_commits - Search across all commits
- git-ls-by-date - List files by last commit date
- git-merged-what-log - Show what was merged
- git-merged-what-show - Display merge details
- git-rank-contributers - Rank contributors by diff size
- git-show-merges - Show merge relationships
- git-status-date - Status with date information
- git-wtf - Comprehensive repository status
- git-credit - Credit authors on commits
- git-extract-folder - Extract folder to new repository
- git-fetch-and-checkout - Fetch and checkout in one command
- git-find_file - Find files across all branches
- git-merge-test - Test merge operations
- git-move-after - Move commits to new positions
- git-move-before - Reorder commits in history
- git-split-amended-commit - Split accidentally merged commits
All scripts implement security best practices:
- Input validation - All user inputs are validated and sanitized
- Command injection protection - No unsafe string interpolation
- Error handling - Comprehensive error checking with meaningful messages
- Git repository validation - Verify git repository before operations
- Safe defaults - Dry-run modes and confirmation prompts for destructive operations
git clone https://github.com/jim-my/git-scripts.git
cd git-scripts
./install.sh# Clone repository
git clone https://github.com/jim-my/git-scripts.git
# Add to PATH (add to your ~/.bashrc or ~/.zshrc)
export PATH="$HOME/git-scripts:$PATH"
# Or copy to local bin directory
cp git-scripts/git-* ~/.local/bin/# Install only specific scripts
cp git-scripts/git-check-dup ~/.local/bin/
cp git-scripts/git-experiment ~/.local/bin/
cp git-scripts/git-wtf ~/.local/bin/# Find duplicate commits between branches
git check-dup origin/main
# Remove duplicates and clean history
git dedupe --apply# Start experiment
git experiment start feature-xyz
# Work on changes...
git add . && git commit -m "experimental changes"
# Keep or discard
git experiment keep # merge back to original branch
git experiment discard # delete experiment entirely# Comprehensive repository status
git wtf
# Enhanced pull with summary
git up # pull with merge
git reup # pull with rebase# 1) In an active conflict/integration flow, start guided mode
git resolve-conflict path/to/file
# -> choose edit view, save changes, and the script auto-retries merge
# -> if merge becomes clean, it applies and stages automatically
# dry-run mode: check retry outcomes without writing/staging resolved output
git resolve-conflict --dry-run path/to/fileGuided mode works for:
- unmerged index entries (normal merge conflict files)
- clean files during an in-progress integration flow (
merge,cherry-pick,revert,rebase)
JSON mode is available for tool integrations:
# audit a historical merge commit for potential conflict-resolution risk
git resolve-conflict --commit [<merge_commit>] path/to/file --json
# find likely-conflicted merge commits (HEAD history by default)
git resolve-conflict --find -- --since='2025-01-01' --author='alice'
# optional path filter with find
git resolve-conflict --find path/to/file -- --since='2025-01-01'--commit ... --json fields:
status-okorerrorconflict_likely-trueif replaying original ours/base/theirs suggests textual conflictreason- reason code for analysis outcome (for examplemerge_file_conflict,both_added_different_content,missing_in_*)resolved,original_ours,original_theirs,original_base- temp file paths for direct diff review
--find status semantics:
likely_had_conflicts- at least one analyzed file looked conflict-pronelikely_clean- analyzed files looked cleanstatus_unknown(non_comparable_only)- no files were analyzable for that merge commit
# Compare untracked files in your working tree against files tracked in the target ref
git untracked-conflict origin/main
# Also show inline diffs for files that differ
git untracked-conflict origin/main --diff
# Delete only the files classified as identical (interactive confirmation)
git untracked-conflict origin/main --delete-identical
# Non-interactive deletion (e.g. scripts/CI)
git untracked-conflict origin/main --delete-identical --yesOutput buckets:
Identical (safe to delete)- local untracked file is byte-identical to target refDifferent (review before merge)- local file differs from target ref version
--delete-identical safety:
- Interactive terminals prompt before deleting.
- Non-interactive runs require
--yesor the command exits with an error.
Checks exact path overlaps only (does not detect file/directory prefix collisions).
# Search through commit history
git search-in-each-commit --keyword "TODO" --since "2024-01-01"
# Find files in current branch trees
git find_file "config\\.yml" --local
# Find file touches in branch history
git find_file "settings\\.py" --history --local
# Find deleted file events
git find_file "legacy\\.txt" --deleted --local
# Find when commit reached main branch
git when-reached-branch abc1234 main
# List files by last modification
git ls-by-date --sortSome scripts work better together:
- git-check-dup + git-dedupe - Complete duplicate management
- git-experiment + git-stash-smart - Enhanced experimental workflow
- git-up/reup + git-wtf - Comprehensive sync and status workflow
- Git 2.0+ (most scripts work with older versions)
- Bash 4.0+ (for bash scripts)
- Ruby 2.0+ (for ruby scripts)
- Python 3.6+ (for python scripts)
- vim - For git-branch-diff, git-show-vim
- icdiff - For git-show2, git-icdiff (
pip install icdiff)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-script) - Follow existing patterns:
- Add proper error handling
- Include comprehensive documentation
- Use security best practices
- Add usage examples
- Test your script thoroughly
- Submit a pull request
- Use
set -euo pipefailfor bash scripts - Validate all inputs
- Provide
--helpdocumentation - Include usage examples in header
- Follow naming convention:
git-action-description
MIT License - Feel free to use and modify
- Inspired by jwiegley/git-scripts
- git-when-reached-branch based on git-when-merged by Michael Haggerty
- Built on top of Git's excellent foundation
- Community contributions and feedback
- Issues: Report bugs or request features via GitHub Issues
- Discussions: Share workflows and ask questions in Discussions
- Security: Report security issues privately via email
Complete list of all 50 scripts (click to expand)
- git-amend
- git-branch-current
- git-branch-diff
- git-branch-new_and_track
- git-branch-not-merged
- git-branch-set_tracking
- git-branch-show
- git-branch-tracking
- git-check-dup
- git-credit
- git-delete-local-merged
- git-diff_with_prev
- git-resolve-conflict
- git-diff-branch
- git-diff-changed_files
- git-diff-theirs_combined
- git-diff-with-2nd-parent.rb
- git-experiment
- git-extract-folder
- git-fetch-and-checkout.rb
- git-find_file
- git-icdiff
- git-incoming
- git-log-merges.rb
- git-log-search_all_commits
- git-ls-by-date.sh
- git-merge-test
- git-merged-what-log
- git-merged-what-show
- git-move-after
- git-move-before
- git-promote
- git-rank-contributers
- git-remove-from-history
- git-dedupe
- git-reup
- git-search-in-each-commit
- git-show-merges
- git-show-vim
- git-show2
- git-split-amended-commit
- git-stage-all
- git-stash-smart
- git-status-date
- git-undo
- git-untracked-conflict
- git-up
- git-when-reached-branch
- git-wtf
β Star this repository if you find it useful!