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