In config management, it is best to do setup in an idempotent way. After some basic research here's a way to clone a repository in an idempotent way. In this example we'll be cloning my
home repository into ${HOME}/git/home.
First, check to see if the repository directory exists. Then change the working directory to it.
Code:
#variables
repo="https://github.com/samrocketman/home.git"
local_repo_location="${HOME}/git/home"
...