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
- 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
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
-
Copy
gitpull.shinto the directory containing your repos. -
Make it executable:
chmod +x gitpull.sh
-
Run it:
./gitpull.sh
| 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.
π 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!
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.
Run it daily to keep your repos fresh:
0 9 * * * /path/to/gitpull.sh