Skip to content

Instantly share code, notes, and snippets.

@mkjsix
Last active August 8, 2025 08:57
Show Gist options
  • Select an option

  • Save mkjsix/7adce1aefb93c5be403c7ae6f487281b to your computer and use it in GitHub Desktop.

Select an option

Save mkjsix/7adce1aefb93c5be403c7ae6f487281b to your computer and use it in GitHub Desktop.
Apply a git command recursively in all folders
#!/bin/bash
# git-all.sh - Execute git commands on all repositories recursively
# Usage: ./git-all.sh "pull --rebase"
# ./git-all.sh "status"
# ./git-all.sh "fetch"
if [ $# -eq 0 ]; then
echo "Usage: $0 \"git-command\""
echo "Examples:"
echo " $0 \"pull\""
echo " $0 \"pull --rebase\""
echo " $0 \"status\""
echo " $0 \"fetch\""
exit 1
fi
find . -type d -name .git -exec sh -c "cd \"{}\"/../ && pwd && git $1" \;
@mkjsix
Copy link
Copy Markdown
Author

mkjsix commented Apr 26, 2017

Example usage: $ ./git-all.sh "pull --rebase"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment