Skip to content

Instantly share code, notes, and snippets.

@erkekin
Last active January 24, 2018 11:03
Show Gist options
  • Save erkekin/f10573cad22f5a37e02c2d6f4a63f83f to your computer and use it in GitHub Desktop.
Save erkekin/f10573cad22f5a37e02c2d6f4a63f83f to your computer and use it in GitHub Desktop.
Fetches all branches of different git repositories in a directory
# Creat a directory called all-repos, and clone all projects into it.
mkdir all-repos
cd all-repos
git clone THEPROJECT1-GIT-ADDRESS project1
git clone THEPROJECT2-GIT-ADDRESS project2
.
.
.
# Create a shell script file called fetchall.sh in the all-repos directory
vi fetchall.sh
#paste the code below
#!/bin/bash
for branch in `git branch -r | grep -v HEAD | grep -v master`; do
echo ${branch##*/} $branch
done
git fetch --all
git pull -v
# end
# run this to fetch all branches of folders in "all-repos" directory
for d in ./*/*/ ; do (cd "$d" && cp ../../fetchall.sh . && sh fetchall.sh && rm fetchall.sh); done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment