This repository has been archived by the owner on Aug 17, 2019. It is now read-only.
/
githelper
executable file
·73 lines (66 loc) · 1.76 KB
/
githelper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#! /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