Check the PHP version before running git or Composer and change it accordingly
php --version update-alternatives --config php #Consider to activate php modules if the following is happening: Your Composer dependencies require a PHP version ">= 8.1.0". a2enmod php8.2