If you pass a local source folder to the az acr build command, the .git folder is excluded from the uploaded package by default. You can create a .dockerignore file with the following setting. It tells the command to restore all files under .git in the uploaded package.
!.git/**
This setting also applies to the az acr run command.