deploy.sh: Improve script to do git checks and discard changes

 * Put cloning into a function and make it remove the old repo
   before doing a fresh clone.
 * Add git check-objects and attempt to do a fresh clone.
 * We now do shallow clones
 * Do a forced checkout to dicard local modification or corruption