Skip to content

Instantly share code, notes, and snippets.

@humangrass
Last active May 6, 2024 12:43
Show Gist options
  • Save humangrass/d471e5d52b1a9e368b714ea83f954000 to your computer and use it in GitHub Desktop.
Save humangrass/d471e5d52b1a9e368b714ea83f954000 to your computer and use it in GitHub Desktop.
A tool for quickly updating projects. Use `chmod +x puller.sh` to make it executable
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <path_to_projects_folder>"
exit 1
fi
pull_if_git_repo() {
local dir="$1"
if [ -d "$dir/.git" ]; then
echo "Pulling changes in $dir"
(cd "$dir" && git pull)
fi
}
recursive_git_pull() {
local folder="$1"
for item in "$folder"/*; do
if [ -d "$item" ]; then
pull_if_git_repo "$item"
recursive_git_pull "$item"
fi
done
}
folder="$1"
if [ ! -d "$folder" ]; then
echo "Folder $folder does not exist"
exit 1
fi
pull_if_git_repo "$folder"
recursive_git_pull "$folder"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment