check whether current directory is inside a git repo

add a function to check if current directory is inside a git repo. If not, return with an error code.