Skip to content

Instantly share code, notes, and snippets.

@jellesiderius
Created February 27, 2023 12:02
Show Gist options
  • Save jellesiderius/10091727fda9f6e91bc68a98213ee38c to your computer and use it in GitHub Desktop.
Save jellesiderius/10091727fda9f6e91bc68a98213ee38c to your computer and use it in GitHub Desktop.
Bash script to reset + pull all latest git versions of underlying folders
#!/bin/bash
# Loop through all directories in the current directory
for dir in */; do
# Enter the directory
cd "$dir"
# Check if the directory is a git repository
if [ -d ".git" ]; then
# Reset the repository to the latest version and pull the latest changes
git reset --hard HEAD
git pull
fi
# Return to the parent directory
cd ..
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment