-
-
Save barend/95aa93e858b9d3104cd0715874a3d6ca to your computer and use it in GitHub Desktop.
Update all git repositories under PWD or $1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Update all git repositories under PWD or $1 | |
# Assumes basic `git clone` usage; may not work for more elaborate git layouts. | |
BASEDIR="${1:-.}" | |
SSH_KEY_NAME="..." # some distinguishing string from your ssh-add -l output | |
SSH_KEY_FILE="..." # the filename of your SSH key | |
if ssh-add -l | grep -F -q $SSH_KEY_NAME; then | |
echo "key in agent" >/dev/null | |
else | |
ssh-add -t 8h "$SSH_KEY_FILE" | |
fi | |
PROJECTS="$(find "$BASEDIR" -name .git -and -type d -print0 | xargs -0 -n1 dirname)" | |
for proj in $PROJECTS; do | |
echo -e "\e[1;96m$proj\e[0m" | |
git -C "$proj" pull --ff-only --recurse-submodules --tags --all --stat --prune | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment