-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-all
More file actions
executable file
·30 lines (26 loc) · 842 Bytes
/
git-all
File metadata and controls
executable file
·30 lines (26 loc) · 842 Bytes
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
#!/bin/zsh -i
# Given a folder that contains multiple git repository folders, this script runs a git command in all of them
#
#
# e.g. given this directory structure:
# - current-working-dir
# -- repo1
# -- repo2
#
# , `git all pull --rebase` will `pull --rebase` both repo1 and repo2
#
# git-all resolves alias: Given `alias gst=git status`, then `git all gst` will be equal to `git all status`
commandOrAlias=$1
commandArgs=`echo $@ | cut -s -d ' ' -f 2-`
resolvedAlias=`alias $commandOrAlias | sed s/\'//g | cut -d ' ' -f 2-`
command=$commandOrAlias
if [ "$resolvedAlias" != "" ]; then
command=$resolvedAlias
fi
fullCommand="git $command $commandArgs"
echo $fullCommand
for folder in $(find . -name .git -type d); do
dir=$(dirname $folder)
printf "\n------\n$dir\n------\n"
bash -c "cd $(dirname $folder) && $fullCommand"
done