Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 74 lines (66 sloc) 1.76 KB
#! /bin/bash
# Written by Ankit R. Gadiya
# Variables
dir="/path/to/repos/locally"
url="https://github.com/username" # Replace username with your's
# Array for repos
declare -a repos=(repo1 repo2) # List all your repos here separated with space
# First Command Line argument
clone="clone"
pull="pull"
fetch="fetch"
setting="set"
help="--help"
# More variables
arg=$1
pwd=`pwd`
# Script
if [ $# = 0 ]
then
echo "Try again with command line arguments"
echo "For help use --help"
fi
if [ $# = 1 ]
then
cd $dir
if [ "$1" == "$clone" ]
then
for i in "${repos[@]}"
do
git $arg $url/$i
done
elif [ "$1" == "$pull" ]
then
for i in "${repos[@]}"
do
cd $i
git $arg
cd ..
done
elif [ "$1" == "$fetch" ]
then
for i in "${repos[@]}"
do
cd $i
git fetch --all
cd ..
done
elif [ "$1" == "$help" ]
then
echo "╦ ╦┌─┐┬ ┌─┐"
echo "╠═╣├┤ │ ├─┘"
echo "╩ ╩└─┘┴─┘┴ "
echo "A small script to perform git commands on a whole bunch of repos together"
echo "Usage: githelper <options>"
echo "Currently supported functions:"
echo "* clone"
echo "* pull"
echo "* fetch"
elif [ "$1" == "$setting" ]
then
nano ~/.scripts/githelper
else
echo "Not supported"
fi
fi
cd $pwd