Skip to content

rahulagr96/bash_scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸŒ€ gitpull.sh – Fetch & Pull All Your Git Repos in One Go

Keep all your Git repositories fresh with a single command! This script will:

  • πŸ” Scan for Git repositories up to a set depth (default: 2)
  • πŸ“¦ Detect which ones are Git repositories
  • ⬇️ Fetch all branches from all remotes (with pruning)
  • πŸ”„ Pull the latest changes for the currently checked-out branch
  • πŸ“Š Show you a colorful, emoji-packed summary at the end

✨ Features

  • Configurable search depth – default is 2 levels deep
  • Hands-off updates – runs through every repo it finds
  • Safe pulls – only pulls the branch you’re currently on
  • Full fetch – keeps all branch refs up-to-date
  • Pretty output – dividers, emojis, and clear sections
  • Summary report – see updated, skipped, and failed repos in one view

πŸ“‚ Example Setup

If your directory looks like this:

.
β”œβ”€β”€ project-a/
β”œβ”€β”€ project-b/subproject-b1
β”œβ”€β”€ project-b/subproject-b2
β”œβ”€β”€ project-c/
└── gitpull.sh

With default depth of 2, it will find:

project-a
project-b/subproject-b1
project-b/subproject-b2
project-c

πŸš€ Installation

  1. Copy gitpull.sh into the directory containing your repos.

  2. Make it executable:

    chmod +x gitpull.sh
  3. Run it:

    ./gitpull.sh

βš™οΈ Options

Option Description Example
-d N Set scan depth to N ./gitpull.sh -d 3
DEPTH=N Set scan depth via env var DEPTH=1 ./gitpull.sh

Default depth is 2.


πŸ–₯ Example Run

πŸš€ Scanning for Git repos (max depth: 2)...

────────────────────────────────────────────────────────────
πŸ“¦ project-a
🌐 Remotes:
origin  git@github.com:user/project-a.git (fetch)
⬇️  git fetch --all --prune
πŸ”„ git pull --rebase --autostash (on main)
βœ… Updated project-a (a1b2c3d Fix login bug)

────────────────────────────────────────────────────────────
πŸ“¦ project-b/subproject-b1
🌐 Remotes:
origin  git@github.com:user/subproject-b1.git (fetch)
⬇️  git fetch --all --prune
⚠️  Detached HEAD β€” skipping pull (fetch already done).

────────────────────────────────────────────────────────────
πŸ“Š Summary
  πŸ“ Repos found: 2
  βœ… Updated    : 1
  ⚠️  Skipped     : 1
  ❌ Failed      : 0
────────────────────────────────────────────────────────────
πŸŽ‰ All done!

πŸ›‘ Safe by Default

This script does not:

  • Force-checkout other branches
  • Merge or rebase multiple branches
  • Delete local work

Instead, it fetches everything and pulls only your current branch.


πŸ’‘ Tip

Run it daily to keep your repos fresh:

0 9 * * * /path/to/gitpull.sh

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages