Skip to content
/ gfash Public

bash script to fetch multiple git repositories in parallel

Notifications You must be signed in to change notification settings

kwo/gfash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

gfa - Git Fetch All

A lightweight bash utility that discovers and manages all Git repositories within the current directory. Scans subdirectories for .git folders and performs batch git operations (fetch, status check, pull) across all discovered repositories in parallel, with real-time color-coded table display.

Features

  • Parallel Processing - All repositories are processed concurrently using background jobs
  • Real-time Display - Live-updating color-coded table showing the status of each repository
  • Auto-discovery - Automatically finds all Git repositories in subdirectories
  • Smart Operations:
    • Fetches from all remotes with pruning
    • Shows branch and dirty/clean status
    • Automatically pulls when behind remote (only if working directory is clean)
  • Visual Feedback:
    • Color-coded status (green=clean, yellow=dirty, red=error)
    • Progress tracking with animated "working..." indicator
    • Responsive terminal table that auto-sizes to content

Installation

Quick Install

# Clone the repository
git clone <repository-url>
cd gfash

# Copy to your bin directory (or any directory in your $PATH)
make deploy

Manual Install

# Copy the script to a location in your PATH
cp gfa ~/bin/gfa
chmod +x ~/bin/gfa

Usage

Navigate to a directory containing multiple Git repositories (or a single repository) and run:

gfa

Example Output

DIRECTORY    BRANCH     STATUS     REMOTE               ACTION
repo1        main       clean      up-to-date           fetched
repo2        develop    dirty      ahead 2              fetched
repo3        feature    clean      behind 3             pulled
repo4        main       clean      no remote branch     fetched

Color Coding

  • Status Column:

    • 🟢 clean - Working directory is clean
    • 🟡 dirty - Uncommitted changes present
    • 🔴 error - Git operation failed
    • 🟡 no git - Directory is not a git repository
  • Remote Column:

    • 🟢 up-to-date - Branch is synchronized with remote
    • 🟡 behind N - Local branch is behind remote by N commits (will auto-pull if clean)
    • 🟡 ahead N - Local branch is ahead of remote
    • 🟡 no remote / no remote branch - No remote configured
  • Action Column:

    • 🟢 fetched - Successfully fetched from remotes
    • 🟢 pulled - Successfully pulled updates from remote

How It Works

  1. Discovery Phase - Scans current directory for subdirectories containing .git folders
  2. Parallel Processing - Spawns a background process for each repository
  3. Per-Repository Operations:
    • Verifies it's a valid Git repository
    • Gets current branch name
    • Checks for uncommitted changes (dirty/clean status)
    • Fetches from all remotes with --prune and --prune-tags
    • Checks remote tracking status
    • Auto-pulls if behind remote and working directory is clean
  4. Real-time Updates - Status table redraws as each operation completes

Development

Linting

The script uses shellcheck for static analysis:

make lint

Requirements

  • Bash 4.0+
  • Git

License

MIT

About

bash script to fetch multiple git repositories in parallel

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors