dkc dkc - 8 months ago 57
Bash Question

Shell script for authenticating github credential

I have shell script and I am cloning master branch into some directory. However I have other steps to follow once I successfully cloned master branch in specified directory. Is there anyway with below command that it returns something true|false so I can do other steps?

git clone -b master /path/to/dir

I have other way around for this but wanted to know if there is some possibility of this.



The git clone command uses exit code 0 on success and non-zero on failure, just like any well-behaving program. You can use this in conditional statements, for example:

if git clone -b master repourl /path/to/dir; then
    # clone successful -> run setup script
    echo fatal: could not clone repo