Skip to content

Instantly share code, notes, and snippets.

@bjorg
Created May 13, 2024 18:01
Show Gist options
  • Save bjorg/3e6cda45943759176ff20374bc0db28e to your computer and use it in GitHub Desktop.
Save bjorg/3e6cda45943759176ff20374bc0db28e to your computer and use it in GitHub Desktop.
Script for running 'git pull' in every folder
#!/bin/bash
# Default to the current directory if no directory is provided
REPO_DIR="${1:-.}"
# Check if the directory exists
if [ ! -d "$REPO_DIR" ]; then
echo "Directory does not exist: $REPO_DIR"
exit 1
fi
# Navigate to the directory
cd "$REPO_DIR"
# Loop through each subdirectory and run 'git pull'
for dir in */ ; do
if [ -d "$dir/.git" ]; then # Check if it's a git repo
echo "Pulling in $dir"
cd "$dir"
git pull
cd ..
else
echo "Skipping $dir - not a git repository."
fi
done
echo "Git pull complete for all repositories."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment