@MarkKaplun You could probably do this with hooks. But what I personally do is using Capistrano or Deployer or alike for deployment.
What they basically do is create a new folder, git pull, composer install and whatever further preparations are needed. The webroot of the webserver then is a symlink to that folder. Repeat this for the next deployment. The symlink is only changed once everything is ready. So the site is never down/in maintenance mode.