Skip to content

Instantly share code, notes, and snippets.

@brunohubner
Created August 6, 2025 14:10
Show Gist options
  • Select an option

  • Save brunohubner/a853fae3ac8d71dd337d7da2a2ea9fa3 to your computer and use it in GitHub Desktop.

Select an option

Save brunohubner/a853fae3ac8d71dd337d7da2a2ea9fa3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
REPOS=(
"repo-name-01"
"repo-name-02"
"repo-name-03"
)
ORIGINAL_DIR=$(pwd)
for REPO_NAME in "${REPOS[@]}"; do
REPO_DIR="/home/user/repos-dir/${REPO_NAME}"
if [ -d "$REPO_DIR" ]; then
(
cd "$REPO_DIR"
if [ -d ".git" ]; then
echo ">> Limpando e atualizando o repositório: ${REPO_DIR}"
rm -f .git/index.lock
git reset --hard
git clean -fd
git checkout main || git checkout master || git checkout dev || true
git pull origin main || git pull origin master || git pull origin dev
# git clsMain || git clsMaster || true
else
echo ">> Aviso: Diretório '${REPO_NAME}' não é um repositório git. Pulando."
fi
)
else
echo ">> Aviso: Diretório '${REPO_NAME}' não encontrado. Pulando."
fi
done
echo "✅ Processo concluído para todos os repositórios."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment