From 43128906a1b095d747d02b139fee08c10b11e96e Mon Sep 17 00:00:00 2001 From: Bxio Date: Mon, 23 Jun 2025 15:09:24 +0100 Subject: [PATCH] --- teste.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/teste.sh b/teste.sh index a6a9a84..afecc10 100644 --- a/teste.sh +++ b/teste.sh @@ -10,8 +10,21 @@ echo -e " echo "Today is " `date` -echo -e "\nenter the path to directory" -read the_path +# Atualizar informação do remoto (fetch) +git fetch origin -echo -e "\n you path has the following files and folders: " -ls $the_path \ No newline at end of file +# Verificar se existem atualizações para a branch atual +LOCAL=$(git rev-parse @) +REMOTE=$(git rev-parse @{u}) +BASE=$(git merge-base @ @{u}) + +if [ "$LOCAL" = "$REMOTE" ]; then + echo "Repositório já está atualizado." +elif [ "$LOCAL" = "$BASE" ]; then + echo "Existem atualizações. A fazer git pull..." + git pull +elif [ "$REMOTE" = "$BASE" ]; then + echo "Repositório local tem commits que o remoto não tem." +else + echo "Repositório local e remoto divergiram." +fi \ No newline at end of file