-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpullall.sh
31 lines (23 loc) · 872 Bytes
/
pullall.sh
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
#!/bin/bash
BASE_DIR=$(pwd);
printf "Pulling in latest changes for all repositories...\n\n";
# Find all git repositories and update it to the main latest revision
for i in $(find . -name ".git" -maxdepth 2 | cut -c 3-); do
# We have to go to the .git parent directory to call the pull command
cd "$i";
cd ..;
CUR_FILE_FULLPATH=$(pwd)
CUR_FILENAME="$(basename -- "$CUR_FILE_FULLPATH")"
CUR_BRANCH=$(git branch --show-current)
printf "=================== %s @ %s ===================\n" $CUR_FILENAME $CUR_BRANCH;
# Switch to main branch
# git checkout main;
# Pull
git pull;
git fetch;
git branch | grep -v "main" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | xargs git branch -D;
printf "\n";
# Go back to the base parent directory
cd $BASE_DIR;
done
printf "Completed fetching latest changes!\n";