-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_all.sh
More file actions
executable file
·34 lines (26 loc) · 811 Bytes
/
fetch_all.sh
File metadata and controls
executable file
·34 lines (26 loc) · 811 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
31
32
33
34
#!/usr/bin/env bash
# Script used to "git pull" into all repositories, beginning from the root directory.
# It actually fetches first, then if not on a feature branch, reset to origin.
function fetch {
# git fetch --prune --all
git fetch --all
}
function git_current_branch {
git rev-parse --abbrev-ref HEAD
}
function is_master {
local branch="${1}"
local master_branches="master main trunk base"
echo "${master_branches}" | grep -w "${branch}" > /dev/null
}
find . -maxdepth 2 -type d -name ".git" | while read _directory; do
_dir_with_repo=${_directory%.*} # Removes the '.git' at the end
pushd "${_dir_with_repo}"
echo "Inside ${_dir_with_repo} ..."
fetch
if is_master $(git_current_branch); then
git reset origin/$(git_current_branch) --hard
fi
popd
echo "---"
done